Skip to content

Handling a continuous flow of records with Spark's structured streaming

Spark Structured Streaming in Microsoft Fabric enables near-real-time processing of data within notebooks using DataFrames, treating a live data stream as an unbounded table that is incrementally processed. It integrates with Fabric's lakehouse architecture, allowing you to read from sources like files or event streams and write results to Delta tables using familiar Spark APIs.

1 · Learn the must-know

  • Structured Streaming uses the same DataFrame/Dataset API as batch processing, so most transformations (select, filter, groupBy, joins) work identically on streaming DataFrames.
  • You create a streaming DataFrame with spark.readStream (e.g., specifying format like 'cloudFiles' for Autoloader-style ingestion or 'delta' for reading a Delta table as a stream) and write output with df.writeStream.
  • Output modes matter: 'append' only writes new rows and is required for most non-aggregated queries, 'complete' rewrites the full result table (used with aggregations), and 'update' writes only changed rows.
  • Checkpointing (via the checkpointLocation option) is mandatory for fault tolerance: it tracks progress and offsets so a restarted stream resumes exactly where it left off without data loss or duplication.
  • Trigger intervals control processing cadence: default is micro-batch as fast as possible, but you can set a fixed interval (e.g., trigger(processingTime='1 minute')) or use Trigger.AvailableNow/once for batch-like one-time processing of available data.
  • In Fabric, streaming writes commonly target Delta tables in the Lakehouse, enabling downstream consumption via SQL endpoints, Power BI, or further Spark jobs; watermarking is used to handle late-arriving data in stateful aggregations.

2 · Check your understanding

Check this objectiveFree · always available

A data engineer builds a Fabric notebook that reads from an event stream and uses Spark Structured Streaming to write the results to a Delta table in a lakehouse with writeStream. The job needs to be restartable so that after a failure or a manual stop and restart, it resumes exactly where it left off without reprocessing or losing records. Which configuration should the engineer set on the streaming query?

Your objective map0 tried · 0 answered correctly · 54 untouched

What you have tried across DP-700's objectives, not a readiness score.

Implement and manage an analytics solution30-35% of the exam0 of 18 tried
Ingest and transform data30-35% of the exam0 of 19 tried
Monitor and optimize an analytics solution30-35% of the exam0 of 17 tried

3 · Keep going