CertLumen

Databricks Data Engineer Professional · Section 1 · 23% of the exam

Apply Structured Streaming stateful-processing semantics, including watermarks, output modes, foreachBatch, and checkpoints for fault-tolerant exactly-once state recovery.

One of the objectives of the Databricks Certified Data Engineer Professional exam, in the section “Developing Code for Data Processing using Python and SQL”. Here is what it covers, the points to remember and a question to try.

What it covers

Reason precisely about stateful streaming: how watermarks bound state, what each output mode emits, how foreachBatch and checkpoints give fault-tolerant, effectively exactly-once results, which query changes a checkpoint survives, and when hand-written Structured Streaming is a better fit than Lakeflow Spark Declarative Pipelines.

Points to remember

  • Watermark = max event time seen minus the delay; data within the delay is always processed, later data may be dropped; state older than the watermark is evicted.
  • Multiple watermarks: default policy min (slowest stream wins); max is lower latency but can drop data.
  • Append (default) emits final rows only, delayed by the watermark; update emits changed rows; complete rewrites everything and never drops state.
  • Delta sinks support append and complete, not update; use foreachBatch + MERGE for upserts.
  • foreachBatch(batch_df, batch_id) is at-least-once; make it idempotent with txnAppId + txnVersion or a sequenced MERGE.

Try a question

A team is choosing between a Lakeflow pipeline and Structured Streaming in a Lakeflow Job for a new streaming workload. Which requirement is a valid reason to choose Structured Streaming?

  1. AThe stream must publish its output to a Kafka topic for a downstream microservice
  2. BThe data must be processed continuously with a latency of a few seconds
  3. CThe team must control checkpoint locations and query restarts in its own code
  4. DChanges from a CDC feed must be applied to an SCD Type 2 dimension table
Show the answer

C. Lakeflow pipelines manage checkpoints, retries and restarts for you, and they support Kafka sinks, continuous mode and AUTO CDC. Choose Structured Streaming when you need explicit control, such as your own checkpoint locations, trigger and restart handling, or custom stateful logic.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Stateful Structured Streaming and Choosing It over Declarative Pipelines teaches this objective (about 60 minutes), and 13 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 45 objectives · Next objective →