nerdexam
Databricks

CERTIFIED-DATA-ENGINEER-PROFESSIONAL · Question #19

A junior data engineer has been asked to develop a streaming data pipeline with a grouped aggregation using DataFrame df. The pipeline needs to calculate the average humidity and average temperature…

The correct answer is B. window("event_time", "5 minutes").alias("time"). Spark Structured Streaming uses the window() function to define time-based grouping windows. For non-overlapping (tumbling) five-minute intervals, the correct syntax is window("event_time", "5 minutes"), which creates fixed windows of exactly 5 minutes with no overlap. Option A…

Streaming Data Processing

Question

A junior data engineer has been asked to develop a streaming data pipeline with a grouped aggregation using DataFrame df. The pipeline needs to calculate the average humidity and average temperature for each non-overlapping five-minute interval. Events are recorded once per minute per device. Streaming DataFrame df has the following schema:

"device_id INT, event_time TIMESTAMP, temp FLOAT, humidity FLOAT" Code block:

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

Exhibit

CERTIFIED-DATA-ENGINEER-PROFESSIONAL question #19 exhibit

Options

  • Ato_interval("event_time", "5 minutes").alias("time")
  • Bwindow("event_time", "5 minutes").alias("time")
  • C"event_time"
  • Dwindow("event_time", "10 minutes").alias("time")
  • Elag("event_time", "10 minutes").alias("time")

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    73% (22)
  • C
    3% (1)
  • D
    7% (2)
  • E
    13% (4)

Explanation

Spark Structured Streaming uses the window() function to define time-based grouping windows. For non-overlapping (tumbling) five-minute intervals, the correct syntax is window("event_time", "5 minutes"), which creates fixed windows of exactly 5 minutes with no overlap. Option A (to_interval) does not exist as a Spark function. Option C (just "event_time") would group by exact timestamp rather than a window. Option D uses 10-minute windows, which does not match the requirement. Option E (lag()) is a window analytical function unrelated to time-based stream windowing.

Topics

#Spark Structured Streaming#Window Functions#Data Aggregation#DataFrame API

Community Discussion

No community discussion yet for this question.

Full CERTIFIED-DATA-ENGINEER-PROFESSIONAL Practice