Databricks Data Engineer Professional exam dumps

Databricks Data Engineer Professional practice question 93 of 313

Databricks Certified Data Engineer Professional. Professional level, Databricks. Free question with the correct answer and a full explanation.

Databricks Data Engineer Professional Question 93

Single answer

You are implementing a Spark Structured Streaming application to process a real-time stream of transaction data. The data contains duplicate records, and your task is to ensure that only unique records are written to the output sink. Each record has a unique transaction_id. How can you implement deduplication in Spark Structured Streaming to achieve this?

  1. A

    Use the dropDuplicates transformation on the streaming DataFrame and specify the transaction_id column.

  2. B

    Use the distinct transformation on the streaming DataFrame.

  3. C

    Apply a watermark on the timestamp column and use the dropDuplicates transformation with the transaction_id column.

  4. D

    Use the groupBy operation on the transaction_id column and apply an aggregation to keep only the first occurrence.

Show answer and explanation

Correct answer: C

Explanation

In Spark Structured Streaming, deduplication in real-time streams is best achieved by combining a watermark with the dropDuplicates transformation. The watermark ensures that only data within a specific time window is considered, preventing unbounded state growth. The dropDuplicates transformation removes duplicates based on the specified column (in this case, transaction_id). This approach is optimal for handling streaming data with late arrivals and ensuring memory efficiency.

  • A. Incorrect.

    The dropDuplicates transformation can remove duplicates based on a specific column, but without a watermark, it cannot handle streaming data with late arrivals effectively. It may cause unbounded state growth.

  • B. Incorrect.

    The distinct transformation removes duplicates across the entire DataFrame but does not handle state management or late-arriving data in a streaming context.

  • C. Correct.

    Using a watermark on the timestamp column ensures that old data outside the watermark window is discarded from the state. Combined with dropDuplicates on the transaction_id column, this approach effectively deduplicates records while managing memory efficiently in a streaming context.

  • D. Incorrect.

    While groupBy and aggregation can be used to deduplicate data, it is not the most efficient or recommended method for this use case in Spark Structured Streaming. It requires additional processing and state management logic.

Timed practice exam

Take a Databricks Data Engineer Professional practice test under exam conditions

60 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam