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);maxis 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+MERGEfor upserts. foreachBatch(batch_df, batch_id)is at-least-once; make it idempotent withtxnAppId+txnVersionor 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?
- AThe stream must publish its output to a Kafka topic for a downstream microservice
- BThe data must be processed continuously with a latency of a few seconds
- CThe team must control checkpoint locations and query restarts in its own code
- 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
- Implement scalable Python project structures for Declarative Automation Bundles (formerly Databricks Asset Bundles / DABs) to support modular development and CI/CD integration.
- Apply troubleshooting techniques to dependency conflicts and installation failures for external libraries (PyPI, local wheels, source archives) across serverless, pipeline, and bundle-deployed environments.
- Develop User-Defined Functions (UDFs) using Pandas, Python, and SQL, including Unity Catalog functions for the given constraints.
- Create production-ready data pipelines for streaming data using Lakeflow Pipelines and Auto Loader.
- Create and automate ETL workloads using Lakeflow Jobs via the UI, API, and CLI.
- Choose between a streaming table and a materialized view for a given latency, cost, and refresh requirement.
- Implement CDC pipelines using AUTO CDC APIs (formerly APPLY CHANGES) in Lakeflow Pipelines, including SCD Type 1 and Type 2 via stored_as_scd_type.
- Choose between Spark Structured Streaming and Apache Spark™ Declarative Pipelines for scalable ETL given operational constraints.
- Create Lakeflow Jobs that use control-flow operators such as If/Else conditions and For Each loops.
- Choose appropriate compute and configuration for environments and dependencies — including serverless compute (serverless environments, dependency management, performance mode), high-memory notebook tasks, and auto-optimization settings (e.g., disallowing retries).
- Develop unit and integration tests using assertDataFrameEqual, assertSchemaEqual, DataFrame.transform, and testing frameworks to ensure code correctness.