CertSafari
    Databricks Certified Data Engineer Professional - October 9 onwards· Lessons

    Domain 1 · Lesson 4/45

    Streaming pipelines with Lakeflow Declarative Pipelines and Auto Loader

    Create production-ready data pipelines for streaming data using Lakeflow Pipelines and Auto Loader.

    17 min read
    1.92% of exam
    9 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Explain how a Lakeflow pipeline turns declared datasets and flows into a dependency graph it orchestrates, checkpoints and retries for you
    • Choose between triggered and continuous pipeline mode, and tell interactive development updates apart from scheduled production runs
    • Choose an Auto Loader file discovery mode for a given latency and cost target, including when to set cloudFiles.useNotifications
    • Pick the cloudFiles.schemaEvolutionMode that matches a schema-change policy, and explain what the rescued data column captures
    • Harden an Auto Loader pipeline for production with monitoring, source retention and an unattended run identity

    Key concept

    Declarative pipeline graph — In a Lakeflow pipeline you declare what each dataset should contain, not when to compute it. The pipeline works out the dependencies between datasets, runs them in order, and handles checkpoints, retries and compute itself.

    1.Datasets, flows and the pipeline graph

    A Lakeflow pipeline is made of source files that declare datasets, plus a configuration that says how and where the pipeline runs. The pipeline itself is built on Apache Spark Declarative Pipelines (SDP). You never write the orchestration code. On every update the pipeline starts a cluster, analyses all source files, builds the dependency graph, and then computes or incrementally updates each dataset in dependency order. Upstream datasets are always computed before the ones that read from them. The graph is built from every file in the pipeline, so files can be organised in any order, and one pipeline can mix Python files and SQL files as long as each file uses one language.

    The unit of work inside that graph is the flow. A flow reads from a source, applies your logic and writes to a target. Streaming tables receive streaming flows (Append, or AUTO CDC for change feeds), and materialized views receive batch flows. You can declare a flow implicitly inside a streaming table definition, or separately so that several flows append to the same table. Ingestion usually lands in a streaming table, because a streaming table processes each record from an append-only source exactly once.

    The three dataset types a pipeline can declare
    Dataset typeHow records are processedTypical use
    Streaming tableEach record processed exactly once, assuming an append-only sourceIngestion and incremental processing of continuously growing data
    Materialized viewResults recomputed as needed to reflect the current state of the dataTransformations, aggregations, results shared by many downstream consumers
    ViewEvaluated on demand, not persistedIntermediate transformations and checks inside the same pipeline

    Managed state and recovery come with the declarative model. Streaming tables use checkpoint management that you never configure, and transient failures are retried in widening scopes: first the Spark task, then the flow, then the whole pipeline. A streaming table is owned by one pipeline, and no other pipeline can update it.

    Exactly-once processing has a consequence that catches people out. A row already appended to a streaming table is never re-queried. If you change a query from LOWER(name) to UPPER(name), only new rows come out uppercase. To rewrite the existing rows you have to run a full refresh. For which dataset type fits a given latency and cost target, see streaming tables vs materialized views.

    Checkpoint 1 of 9· Check yourself

    A streaming table in a triggered Lakeflow pipeline has already ingested 10 million rows from Auto Loader. You edit its query to wrap the email column in sha2() so it gets masked. What happens on the next update, and what gets every row masked?

    Sources123

    2.Triggered vs continuous, development vs production

    Pipeline mode decides when an update stops, and it is separate from whether a dataset is streaming. In triggered mode an update refreshes every table using the data that existed when the update started, then shuts down. In continuous mode the pipeline keeps running until someone stops it, processing new data as it arrives. Continuous pipelines avoid wasted work by updating only when the Delta tables they depend on have changed. Both streaming tables and materialized views can run in either mode.

    Triggered is the right default for most pipelines. Continuous mode needs a cluster that never shuts down, so keep it for genuine sub-minute latency requirements. For operational workloads that need sub-second end-to-end latency, a pipeline can also run in real-time mode.

    Development runs and production runs behave differently. Updates you start interactively from the Lakeflow Pipelines Editor reuse the cluster and turn off automatic retries, so a broken query fails quickly while you iterate. A production pipeline should not depend on someone clicking Start. It should be scheduled by the job scheduler or a Lakeflow Job, which is where unattended runs get the managed retry and recovery behaviour.

    Triggered and continuous pipeline mode compared
    QuestionTriggeredContinuous
    When does the update stop?Automatically when completeRuns until manually stopped
    What data is processed?Data available when the update startsNew data as it arrives in sources
    ComputeReleased after each updateAlways-on cluster
    When it winsDefault for the vast majority of pipelinesGenuine sub-minute latency needs

    Checkpoint 2 of 9· Check yourself

    An engineer built an Auto Loader ingestion pipeline and has been running it by clicking Start in the Lakeflow Pipelines Editor each morning. It is now going to run unattended in production. What should change?

    Sources451

    3.Auto Loader and file discovery

    Auto Loader is the Structured Streaming source cloudFiles. You give it a directory in S3, ADLS, GCS or a Unity Catalog volume, and it processes new files as they arrive, optionally including the files already there. It reads JSON, CSV, XML, Parquet, Avro, ORC, text and binary files. Every file it discovers is recorded in a RocksDB key-value store in the checkpoint, which is how it guarantees exactly-once processing and resumes where it stopped after a failure. Inside a Lakeflow pipeline you do not set a schema location or checkpoint location, because the pipeline manages both.

    Auto Loader in a pipeline through read_files, archiving processed files after 14 dayssql
    CREATE OR REFRESH STREAMING TABLE raw_events
    AS SELECT * FROM STREAM read_files(
      's3://my-bucket/landing/',
      format => 'json',
      cleanSource => 'MOVE',
      `cleanSource.moveDestination` => 's3://my-bucket/archive/landing/',
      `cleanSource.retentionDuration` => '14 days'
    );

    Auto Loader can find new files in two ways, and the choice is mostly about cost. Directory listing is the default. It calls the storage LIST API, and a continuous trigger such as Trigger.ProcessingTime is expensive in this mode because Auto Loader keeps listing the entire directory. File notification mode subscribes to storage events and skips listing entirely. On AWS, when cloudFiles.useNotifications is true and Auto Loader is allowed to create the resources, it sets up the SNS and SQS services itself. For a stream whose files land unpredictably across many prefixes, this is the change that removes the billed LIST calls while staying near real time.

    Choosing a file discovery mode
    ModeHow files are foundWhen it wins
    Directory listing (default)Lists the source directory with native cloud APIsNo notification permissions available; triggered or low-frequency runs
    File eventsNotification-based, one queue per bucket, incremental discovery on later runsRecommended for most workloads: low latency and simple setup
    Classic file notification (cloudFiles.useNotifications)Reads directly from the cloud queue, without the caching hop that file events addsVery latency-sensitive applications; resources can be tagged for cost tracking

    Running the same listing source with Trigger.AvailableNow reduces compute cost because the job runs as a scheduled batch instead of an always-on stream. Each run still lists the directory. If you must stay on directory listing, cloudFiles.cleanSource keeps the directory small by moving (MOVE) or deleting (DELETE) files after processing, so fewer files are listed. This option really does move or delete your source files, and a MOVE destination must be in the same external location, volume or mount as the source.

    Checkpoint 3 of 9· Fill the gap

    Processed landing files must be kept in an archive path for auditing, and the directory Auto Loader lists must stay small. Which value completes this pipeline definition?

    CREATE OR REFRESH STREAMING TABLE raw_events
    AS SELECT * FROM STREAM read_files(
      's3://my-bucket/landing/',
      format => 'json',
      cleanSource => ' ? ',
      `cleanSource.moveDestination` => 's3://my-bucket/archive/landing/',
      `cleanSource.retentionDuration` => '14 days'
    );

    Checkpoint 4 of 9· Check yourself

    Files for a near-real-time Auto Loader stream land unpredictably across thousands of prefixes. The stream uses directory listing with Trigger.ProcessingTime, and the storage bill is dominated by LIST calls. Which change removes that cost while keeping latency low?

    Checkpoint 5 of 9· Exam question

    A streaming Auto Loader job reads Parquet files landing in an S3 bucket at roughly 200 files per hour, scattered unpredictably across many prefixes. Continuous directory listing is generating a large volume of billed S3 LIST calls, and the team has granted Databricks permission to create the AWS SNS and SQS resources needed for cloud storage notifications. Which configuration change reduces file discovery cost while keeping the stream close to real time?

    Sources678

    4.Schema inference, evolution and rescued data

    Auto Loader infers the schema, stores it in the schema location, and watches for drift. When a type conflicts across Parquet files, it picks the widest type, and schema hints can override that choice. Values that do not match the expected type go into the rescued data column rather than being dropped. This is how Auto Loader keeps data that would otherwise be ignored or lost.

    The cloudFiles.schemaEvolutionMode option decides what a new column does to the stream. The default, addNewColumns, merges the new columns onto the end of the stored schema and then stops the stream deliberately. The restart picks up the wider schema, and existing columns never change type. Because that stop is expected, run these streams under Lakeflow Jobs with automatic restart. The other modes each match a different policy.

    cloudFiles.schemaEvolutionMode values and their behaviour on a new column
    ModeBehaviour on a new columnUse it when
    addNewColumns (default)Schema updated, stream fails with UnknownFieldException, restart resumes with the new schemaNew fields should flow through after an automatic restart
    failOnNewColumnsStream fails and the schema is not updated, so it stays down until someone changes the schema or removes the fileA human must review every schema change before more rows are written
    rescueSchema never evolves and the stream does not fail; new columns land in the rescued data columnUptime matters more than promoting new fields to columns
    noneSchema does not evolve, new columns are ignored, and nothing is rescued unless a rescued data column is configuredThe schema is fixed and extra fields are noise

    Checkpoint 6 of 9· Check yourself

    In some incoming records, the amount field holds a value that does not match the type Auto Loader inferred and stored for that column. What does Auto Loader do with that value?

    Checkpoint 7 of 9· Exam question

    A production Auto Loader stream ingests JSON files into a bronze Delta table. Compliance requires that if the upstream system starts emitting a new column, the pipeline must stop immediately so an engineer can review the schema change before any further rows are written, rather than silently ingesting rows that contain the new field. Which cloudFiles.schemaEvolutionMode setting satisfies this requirement?

    Sources96

    5.Running it unattended

    A production-ready pipeline runs on a schedule against real data and catches its own failures, instead of hearing about them from a downstream consumer. For Auto Loader, monitoring starts with the stream's own state. The cloud_files_state function lists the files a stream has discovered, given its checkpoint location. Each batch also reports backlog metrics to the Streaming Query Listener.

    Backlog metrics Auto Loader reports at every batchjson
    {
      "sources": [
        {
          "description": "CloudFilesSource[/path/to/source]",
          "metrics": {
            "numFilesOutstanding": "238",
            "numBytesOutstanding": "163939124006"
          }
        }
      ]
    }

    If numFilesOutstanding keeps growing from one batch to the next, ingestion is falling behind arrivals. In file notification mode on AWS and Azure the metrics also include approximateQueueSize, the approximate number of file events waiting in the cloud queue.

    Several production habits come from how the pipeline recovers:

    • Let Spark errors surface. A broad try/except that catches AnalysisException hides real failures from the event log and interferes with managed retry and recovery.
    • Run the pipeline as a service principal, not a personal identity.
    • Deploy it from a bundle with separate dev and prod targets, and parameterise source paths and catalog names.
    • Test what a checkpoint failure looks like before you meet one in an incident.

    Some sources change rows rather than only adding them. For those, apply the changes to a streaming table with an AUTO CDC flow instead of appending. AUTO CDC handles out-of-order events and supports SCD Type 1 and Type 2. Because Auto Loader does not order files, a pipeline combining Auto Loader and AUTO CDC should set pipelines.cdc.tombstoneGCThresholdInSeconds above the longest expected arrival delay. The default retention is two days. The full CDC semantics are taught in AUTO CDC and SCD types.

    Checkpoint 8 of 9· Fill the gap

    You are setting up an alert for an Auto Loader stream that uses directory listing. It should fire when the number of discovered files still waiting to be ingested keeps rising from batch to batch. Which metric name completes the progress report the alert reads?

    {
      "sources": [
        {
          "description": "CloudFilesSource[/path/to/source]",
          "metrics": {
            " ? ": "238",
            "numBytesOutstanding": "163939124006"
          }
        }
      ]
    }

    Checkpoint 9 of 9· Exam question

    A team builds a Lakeflow Declarative Pipelines flow that applies change-data-capture records from a bronze_customers_cdc streaming table into a silver_customers streaming table and must retain full history of every attribute change per customer: CREATE OR REFRESH STREAMING TABLE silver_customers; AUTO CDC INTO silver_customers FROM STREAM bronze_customers_cdc KEYS (customer_id) APPLY AS DELETE WHEN operation = "DELETE" SEQUENCE BY sequence_num STORED AS SCD TYPE 2; Which statements about this configuration are correct?(Select 2)

    0 of 2 selected

    Sources7532

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Pipelines automatically infer dependencies between datasets and arrange them in a directed acyclic graph (DAG).”
      ↩︎ Datasets, flows and the pipeline graph
      “Updates you trigger interactively from the editor optimize for fast iteration, reusing the cluster and disabling automatic retries.”
      ↩︎ Triggered vs continuous, development vs production
      “Pipelines automatically infer dependencies between datasets and arrange them in a directed acyclic graph (DAG).”
      ↩︎ Key concept
    2. 2.
      “A flow reads data from a source, applies user-defined processing logic, and writes the result into a target.”
      ↩︎ Datasets, flows and the pipeline graph
      “retry transient failures progressively: from the Spark task, to the flow, to the entire pipeline.”
      ↩︎ Datasets, flows and the pipeline graph
      “handles out of order CDC events and supports both SCD Type 1 and SCD Type 2”
      ↩︎ Running it unattended
    3. 3.
      “A row that has already been appended to a streaming table will not be re-queried with later updates to the pipeline.”
      ↩︎ Datasets, flows and the pipeline graph
      “use AUTO CDC to apply those changes to a streaming table instead of appending them.”
      ↩︎ Running it unattended
      “A row that has already been appended to a streaming table will not be re-queried with later updates to the pipeline.”
      ↩︎ Exam trap 3
      “To reprocess existing rows that were processed prior to the change, a full refresh is required.”
      ↩︎ Checkpoint
    4. 4.
      “If the pipeline uses triggered mode, the system stops after refreshing all tables based on the data available when the update started.”
      ↩︎ Triggered vs continuous, development vs production
      “Pipeline mode is independent of the type of table being computed.”
      ↩︎ Prediction
    5. 5.
      “Reserve continuous for genuine sub-minute latency needs, since it requires an always-on cluster.”
      ↩︎ Triggered vs continuous, development vs production
      “The pipeline is scheduled through the job scheduler or a Lakeflow Job rather than someone remembering to select Start.”
      ↩︎ Triggered vs continuous, development vs production
      “you don't wrap transformations in broad try/except blocks that catch AnalysisException or other internal Spark exceptions.”
      ↩︎ Running it unattended
      “The pipeline runs as a service principal, not a personal user identity”
      ↩︎ Running it unattended
      “The pipeline is defined and deployed through a bundle, not hand-clicked into existence in the UI”
      ↩︎ Running it unattended
      “Reserve continuous for genuine sub-minute latency needs, since it requires an always-on cluster.”
      ↩︎ Exam trap 4
    6. 6.
      “As files are discovered, their metadata is persisted in a scalable key-value store (RocksDB) in the checkpoint location of your Auto Loader pipeline.”
      ↩︎ Auto Loader and file discovery
      “You do not need to provide a schema or checkpoint location because Lakeflow pipelines automatically manage these settings for your pipelines.”
      ↩︎ Auto Loader and file discovery
      “By default, Auto Loader uses directory listing mode. However, Databricks recommends file notification mode using file events for most workloads.”
      ↩︎ Auto Loader and file discovery
      “Auto Loader does not guarantee the order in which files are discovered or processed”
      ↩︎ Auto Loader and file discovery
      “rescue data that would have been otherwise ignored or lost”
      ↩︎ Schema inference, evolution and rescued data
      “Auto Loader's file notification mode can help reduce your cloud costs further by avoiding directory listing altogether.”
      ↩︎ Exam trap 2
      “Auto Loader's file notification mode can help reduce your cloud costs further by avoiding directory listing altogether.”
      ↩︎ Checkpoint
      “Auto Loader can detect schema drifts, notify you when schema changes happen, and rescue data that would have been otherwise ignored or lost.”
      ↩︎ Checkpoint
    7. 7.
      “Continuous triggers such as Trigger.ProcessingTime are especially expensive in directory listing mode, since Auto Loader continuously lists the entire directory to find new files.”
      ↩︎ Auto Loader and file discovery
      “File events requires only one queue per bucket and uses incremental discovery on subsequent runs.”
      ↩︎ Auto Loader and file discovery
      “Classic mode reads directly from the cloud queue without the additional caching hop introduced by file events.”
      ↩︎ Auto Loader and file discovery
      “Setting cloudFiles.cleanSource deletes or moves files in the source directory.”
      ↩︎ Auto Loader and file discovery
      “Query cloud_files_state, providing the checkpoint location associated with an Auto Loader stream.”
      ↩︎ Running it unattended
    8. 8.
      “only if you choose cloudFiles.useNotifications = true and you want Auto Loader to set up the notification services for you”
      ↩︎ Auto Loader and file discovery
    9. 9.
      “In the case of a mismatch, Auto Loader rescues the column by placing the data in the rescued data column.”
      ↩︎ Schema inference, evolution and rescued data
      “When Auto Loader detects a new column, the stream stops with an UnknownFieldException.”
      ↩︎ Schema inference, evolution and rescued data
      “Restarting the stream resumes processing with the updated schema.”
      ↩︎ Schema inference, evolution and rescued data
      “Restarting the stream resumes processing with the updated schema.”
      ↩︎ Exam trap 1

    Spotted a mistake, or was something unclear? Tell us.