QuestionQ217

VerifiedData Transformation, Cleansing, and Quality

A junior data engineer must build a streaming data pipeline using DataFrame df that performs a grouped aggregation. The pipeline must compute the average humidity and average temperature for each non-overlapping five-minute interval. Events are logged once per minute for each device.

The streaming DataFrame df has this schema:

device_id INT, event_time TIMESTAMP, temp FLOAT, humidity FLOAT

Code block:

Question Image

Which code line correctly completes the blank in the code block to accomplish this task?

Explanation

Spark Structured Streaming performs event-time windowed aggregations by grouping on window(event_time_column, window_duration). Supplying a five-minute duration without a separate slide duration creates tumbling, non-overlapping five-minute windows, while grouping by device_id produces separate averages for each device and interval.

Learn more

Community Discussion

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