QuestionQ216

VerifiedStructured Streaming

A data engineer handles streaming data in which records arrive at random times. The engineer must deduplicate records by order_id while ensuring the latest records are retained in the stream.

Which strategy should the engineer use to deduplicate records while accounting for late-arriving data and managing memory usage?

Explanation

In Structured Streaming, dropDuplicates() can deduplicate a streaming DataFrame using order_id. Applying withWatermark() on an event-time column establishes the lateness threshold and permits Spark to discard old deduplication state, bounding the memory required for stateful processing. Without a watermark, Spark must retain state for all prior records because a duplicate could arrive at any time. PySpark DataFrame.dropDuplicates documentation

Learn more

Community Discussion

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