A data engineer is writing a Structured Streaming job in Azure Databricks that reads raw turbine telemetry from a Kafka topic and writes it, without aggregation, to the Unity Catalog Delta table energy.bronze.turbine_raw. Requirements:
- The query must run indefinitely.
- Each micro-batch must start as soon as the previous micro-batch completes.
- Each reading must be added as a new row, and existing rows must not be rewritten.
- After a restart, the query must resume from where it stopped.
The checkpoint path /checkpoints/grid-raw is already used by a running query that ingests grid telemetry. The path /checkpoints/turbine-raw has never been used.
Which writeStream configuration should the engineer use?
Raw ingestion that simply adds readings uses append output mode, which adds new rows without rewriting existing ones. Omitting the trigger makes the engine start the next batch as soon as the previous batch completes, and the query keeps running. availableNow stops after processing available data, processingTime runs on fixed intervals, and the checkpoint must be unique to this query so it can resume correctly after a restart.
- Not correct:
outputMode("complete"), no trigger, checkpoint/checkpoints/turbine-raw. Complete mode writes the full result of a streaming aggregation after each trigger and requires an aggregation. - Correct:
outputMode("append"), no trigger, checkpoint/checkpoints/turbine-raw. Append adds new rows, the default trigger runs the next batch as soon as the previous one completes and keeps the query running, and the query can resume after a restart by reusing its saved checkpoint at/checkpoints/turbine-raw. - Not correct:
outputMode("append"), no trigger, checkpoint/checkpoints/grid-raw. Each streaming query needs its own unique checkpoint location; sharing the grid telemetry query's checkpoint causes data processing errors. - Not correct:
outputMode("append"),trigger(availableNow=True), checkpoint/checkpoints/turbine-raw. The availableNow trigger processes all available data and then stops, which suits scheduled incremental batches, not a query that runs indefinitely. - Not correct:
outputMode("append"),trigger(processingTime="30 seconds"), checkpoint/checkpoints/turbine-raw. A processingTime trigger processes data in fixed intervals rather than starting the next batch immediately after the previous one completes.