QuestionQ2

VerifiedDeveloping Code for Data Processing using Python and SQL

A junior data engineer must build a streaming data pipeline using DataFrame df that performs a grouped aggregation. The pipeline must calculate average humidity and average temperature for every non-overlapping five-minute interval. Incremental state data must be retained for 10 minutes to accommodate late-arriving data.

The streaming DataFrame df has this schema:

device_id INT, event_time TIMESTAMP, temp FLOAT, humidity FLOAT

Code block:

Question Image

Choose the response that correctly fills the blank in the code block to finish this task.

Explanation

withWatermark("event_time", "10 minutes") defines a 10-minute event-time watermark on the streaming DataFrame. This lets Structured Streaming retain state for the windowed aggregation while accepting late data within that threshold, and eventually evict finalized aggregation state. The five-minute window call without a slide duration creates non-overlapping tumbling windows.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!