QuestionQ263

VerifiedDeveloping Code for Data Processing using Python and SQL

A junior data engineer is asked to build a streaming data pipeline with a grouped aggregation using DataFrame df. The pipeline must calculate average humidity and average temperature for every non-overlapping five-minute interval. Incremental state information 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 complete this task.

Explanation

withWatermark("event_time", "10 minutes") defines the event-time watermark for the streaming DataFrame. Its delay threshold allows late records within the 10-minute threshold to contribute to the event-time window aggregation and enables Spark to manage the aggregation state. A window with only a five-minute duration creates non-overlapping five-minute tumbling windows because its slide duration defaults to the window duration.

Learn more

Community Discussion

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