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

    Domain 1 · Lesson 4/46

    Running Auto Loader Pipelines in Production

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

    12 min read
    1.92% of exam
    4 sources
    Published 2 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Choose between triggered, continuous and Trigger.AvailableNow execution based on latency and cost
    • Select a file discovery mode and use cloudFiles.cleanSource to control discovery and storage cost
    • Monitor an Auto Loader stream with cloud_files_state and backlog metrics, and design for out-of-order file arrival
    • Apply the Lakeflow pipeline production-readiness checklist to a streaming ingestion pipeline

    1.Triggered, continuous, or AvailableNow

    For most production ingestion, Databricks recommends running Auto Loader inside Lakeflow pipelines. A pipeline runs in one of two modes. In triggered mode it processes the data that is available and then stops. In continuous mode it keeps tables fresh as new data arrives. Choose the mode deliberately, because it decides whether you pay for a cluster that never shuts down.

    Triggered mode is the right default for most pipelines. Keep continuous mode for genuine sub-minute latency needs, because it needs an always-on cluster. When latency doesn't matter much and compute cost is the priority, there is a third option outside pipelines. You can use Lakeflow Jobs to schedule Auto Loader as a batch job with Trigger.AvailableNow. Within Lakeflow Jobs, a file arrival trigger can start those batch jobs to cut the delay between a file landing and its processing.

    Execution choices for Auto Loader ingestion
    ChoiceWhen the sources recommend it
    Triggered pipelineDefault for the vast majority of pipelines; scheduled through the job scheduler or a Lakeflow Job
    Continuous pipelineGenuine sub-minute latency needs; requires an always-on cluster
    Lakeflow Job with Trigger.AvailableNowNo low-latency requirement and minimizing compute cost is the priority; can use file arrival triggers

    Checkpoint 1 of 7· 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?

    Checkpoint 2 of 7· Check yourself

    Files land in a volume a few times a day. Reports are read the next morning, and the team wants the lowest compute bill while still reacting to new files. Which setup fits the documented guidance?

    Sources12

    2.File discovery modes and source cleanup

    Auto Loader's main costs are compute and file discovery. In directory listing mode, discovery costs you LIST operations on storage. In notification mode it costs subscription-service and queue API requests. Continuous triggers such as Trigger.ProcessingTime are especially expensive with directory listing, because Auto Loader keeps listing the whole directory. If you need continuous triggers, choose the mode by latency:

    Auto Loader file discovery modes
    ModeCharacteristicsUse when
    Directory listingDefault; lists storage to find new filesYou can't use file events; pair with cloudFiles.cleanSource to keep listings small
    File eventsOne queue per bucket; incremental discovery on subsequent runsLow latency and simplicity; recommended for most workloads
    Classic file notificationReads directly from the cloud queue, without the extra caching hop of file events; supports resource tagsVery latency-sensitive applications

    As files pile up, storage costs rise and discovery slows down. cloudFiles.cleanSource (Databricks Runtime 16.4 LTS and above) archives or deletes files after they are processed. Use MOVE when you have to keep files for compliance. With MOVE, the source and destination must be in the same external location, volume or DBFS mount. Use DELETE to cut storage cost, and enable bucket versioning so deletes act as soft deletes. Inside a pipeline, the same options pass through read_files:

    Lakeflow Declarative Pipeline streaming table that archives 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'
    );

    Checkpoint 3 of 7· Fill the gap

    This Structured Streaming version of the same archive pattern runs as a scheduled batch. Which trigger argument completes it?

    df = (spark.readStream.format("cloudFiles")
      .option("cloudFiles.format", "json")
      .option("cloudFiles.cleanSource", "MOVE")
      .option("cloudFiles.cleanSource.moveDestination", archive_path)
      .option("cloudFiles.cleanSource.retentionDuration", "14 days")
      .option("cloudFiles.schemaLocation", checkpoint)
      .load("s3://my-bucket/landing/")
    )
    
    # Step 2: Write to a Delta table.
    (df.writeStream
      .option("checkpointLocation", checkpoint)
      .trigger( ? =True)
      .toTable("my_catalog.my_schema.raw_events")
    )

    Checkpoint 4 of 7· Check yourself

    A team sets cloudFiles.cleanSource to MOVE with the source in one S3 bucket and the archive in a different bucket. What happens?

    Sources1

    3.Monitoring the stream and handling out-of-order files

    A production stream needs to be observable. Auto Loader exposes the files it has discovered through the cloud_files_state SQL function (Databricks Runtime 11.3 LTS and above). You pass it the stream's checkpoint location:

    Inspect file-level discovery state for an Auto Loader streamsql
    SELECT * FROM cloud_files_state('path/to/checkpoint');

    For ongoing monitoring, Databricks recommends the Streaming Query Listener. Auto Loader reports backlog metrics to it on every batch. In file notification mode on Databricks Runtime 10.4 LTS and above, the metrics also include approximateQueueSize on AWS and Azure.

    Backlog metrics reported per batch by the cloudFiles sourcejson
    {
      "sources": [
        {
          "description": "CloudFilesSource[/path/to/source]",
          "metrics": {
            "numFilesOutstanding": "238",
            "numBytesOutstanding": "163939124006"
          }
        }
      ]
    }

    File order is a separate design problem. Neither discovery mode guarantees the order in which files are found or processed. In a Lakeflow pipeline that combines Auto Loader with AUTO CDC, set pipelines.cdc.tombstoneGCThresholdInSeconds on the target streaming table. Make it longer than the maximum expected delay so deleted records are kept long enough to handle late files. The default is two days. Without pipelines, use soft deletes, and compare timestamps before an upsert so stale records don't overwrite newer ones.

    AUTO CDC is the pipeline flow built for this problem: it handles out-of-order CDC events and supports both SCD Type 1 and SCD Type 2. You tell it how to order changes with a sequencing column (sequence_by in Python, SEQUENCE BY in SQL) and choose the SCD type with stored_as_scd_type (STORED AS SCD TYPE in SQL), so you don't write manual code for out-of-order events or watermarks.

    Checkpoint 5 of 7· 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: ```sql 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)

    Checkpoint 6 of 7· Check yourself

    A pipeline uses Auto Loader with AUTO CDC. Upstream files can arrive up to four days late, and a late delete sometimes resurrects or conflicts with records. What should you change?

    Sources134

    4.The production-readiness checklist

    Databricks defines production readiness as a checklist across data quality, reliability, observability, deployment, cost and governance. For a streaming ingestion pipeline, these are the items that matter most:

    Production-readiness items for a Lakeflow streaming pipeline
    DimensionChecklist item
    Data qualityEvery dataset that can receive bad data has expect, expect_or_drop or expect_or_fail, chosen deliberately per constraint
    ReliabilityScheduled through a Lakeflow Job; failure notifications configured; checkpoint-failure recovery tested
    ReliabilitySpark errors surface, so there are no broad try/except blocks catching AnalysisException
    ObservabilityEvent log queried; system.lakeflow.pipelines checked; update duration trend known
    DeploymentDefined and deployed through a bundle with dev and prod targets; paths and catalogs parameterized
    Cost and governanceServerless versus classic chosen explicitly; runs as a service principal; Unity Catalog with least privilege

    Two items catch people out. The first is error handling. Lakeflow pipelines rely on surfaced failures to manage retry and recovery, so a protective try/except around transformations actually hides real errors from the event log. The second is expectation actions: use fail for conditions that should halt the run, and drop, ideally with a quarantine table, for records you can safely discard.

    An expectation is a SQL boolean constraint on a dataset, and it names what happens when a record fails it: warn, drop the record, or fail the update. In SQL you write it as a constraint such as CONSTRAINT valid_id EXPECT (id IS NOT NULL) ON VIOLATION DROP ROW. In Python, expect_all_or_drop takes a dictionary of named constraints. The tutorial's silver layer uses drop to remove rows with a null ID, an invalid CDC operation, or data Auto Loader could not read correctly (a non-null _rescued_data).

    Checkpoint 7 of 7· Check yourself

    A developer wraps each pipeline transformation in try/except AnalysisException and logs the error, so the pipeline "never fails". Why does the checklist reject this?

    Sources24

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.A production streaming pipeline should run in continuous mode.Why is that wrong?

      Triggered mode is the default for most pipelines. Continuous mode is for genuine sub-minute latency needs, because it requires an always-on cluster.

      Covered in Triggered, continuous, or AvailableNow

    2. 2.Directory listing is the recommended discovery mode because it is the default.Why is that wrong?

      Directory listing is the default, but Databricks recommends file notification mode using file events for most workloads. Directory listing is especially expensive under continuous triggers.

      Covered in File discovery modes and source cleanup

    3. 3.File notification mode processes files in the order they arrive, so it solves out-of-order data.Why is that wrong?

      Neither discovery mode guarantees ordering. Handle late files with tombstone retention (AUTO CDC in pipelines), or with soft deletes and timestamp comparisons.

      Covered in Monitoring the stream and handling out-of-order files

    Practise it for real

    Run an Auto Loader stream as a cost-efficient batch that archives processed files, then inspect its state.

    1. 1.In a notebook, define a cloudFiles read with cloudFiles.format json, cloudFiles.cleanSource MOVE, a cloudFiles.cleanSource.moveDestination in the same external location or volume as the source, cloudFiles.cleanSource.retentionDuration, and cloudFiles.schemaLocation set to your checkpoint path.

      Why: MOVE keeps processed files for auditing and makes later directory listings smaller.

      You should see: The streaming DataFrame is defined without errors. A destination in a different bucket would raise an error.

    2. 2.Write the stream with checkpointLocation set to the same checkpoint and .trigger(availableNow=True) to a Unity Catalog table.

      Why: AvailableNow processes the backlog and then stops, so you don't pay for always-on compute.

      You should see: The query processes the available files and terminates, and the target table holds the ingested rows.

    3. 3.Run SELECT * FROM cloud_files_state('<your checkpoint path>');

      Why: This shows file-level metadata for the files the stream has discovered.

      You should see: One row per discovered file.

    4. 4.Drop a new file into the landing path and run the write again.

      Why: This shows that the checkpoint lets Auto Loader resume and ingest only the new file.

      You should see: Only the new file's rows are added; earlier files aren't re-ingested.

    Stuck? Get a nudge

    If the move fails, check that the source and archive paths are in the same external location, volume or DBFS mount.

    Sources

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

    1. 1.
      “Lakeflow pipelines are the recommended way to run Auto Loader for most production ingestion.”
      ↩︎ Triggered, continuous, or AvailableNow
      “you can reduce compute costs by using Lakeflow Jobs to schedule Auto Loader as batch jobs using Trigger.AvailableNow instead of running it continuously.”
      ↩︎ Triggered, continuous, or AvailableNow
      “Classic mode reads directly from the cloud queue without the additional caching hop introduced by file events.”
      ↩︎ File discovery modes and source cleanup
      “Setting cloudFiles.cleanSource deletes or moves files in the source directory.”
      ↩︎ File discovery modes and source cleanup
      “Query cloud_files_state, providing the checkpoint location associated with an Auto Loader stream.”
      ↩︎ Monitoring the stream and handling out-of-order files
      “You can view how many files exist in the backlog and how large the backlog is in the numFilesOutstanding and numBytesOutstanding metrics”
      ↩︎ Monitoring the stream and handling out-of-order files
      “Continuous triggers such as Trigger.ProcessingTime are especially expensive in directory listing mode”
      ↩︎ Exam trap 2
      “These batch jobs can be triggered using file arrival triggers to further lower the latency between file arrival and processing.”
      ↩︎ Checkpoint
      “Cross-bucket and cross-container moves are not supported and result in an error.”
      ↩︎ Checkpoint
    2. 2.
      “Triggered is the right default for the vast majority of pipelines.”
      ↩︎ Triggered, continuous, or AvailableNow
      “fail for conditions that should stop the world (such as a broken primary key), drop for records you can safely discard”
      ↩︎ The production-readiness checklist
      “you've tested what happens on a checkpoint failure and know the recovery procedure”
      ↩︎ The production-readiness checklist
      “The pipeline is defined and deployed through a bundle, not hand-clicked into existence in the UI”
      ↩︎ The production-readiness checklist
      “The pipeline runs as a service principal, not a personal user identity”
      ↩︎ The production-readiness checklist
      “Reserve continuous for genuine sub-minute latency needs, since it requires an always-on cluster.”
      ↩︎ Exam trap 1
      “you don't wrap transformations in broad try/except blocks that catch AnalysisException or other internal Spark exceptions.”
      ↩︎ Checkpoint
    3. 3.
      “The default retention is two days.”
      ↩︎ Monitoring the stream and handling out-of-order files
      “Auto Loader does not guarantee the order in which files are discovered or processed”
      ↩︎ Exam trap 3
      “By default, Auto Loader uses directory listing mode. However, Databricks recommends file notification mode using file events for most workloads.”
      ↩︎ Prediction
      “Set the pipelines.cdc.tombstoneGCThresholdInSeconds table property on the target streaming table”
      ↩︎ Checkpoint
    4. 4.
      “handles out of order CDC events and supports both SCD Type 1 and SCD Type 2”
      ↩︎ Monitoring the stream and handling out-of-order files
      “You define an expectation as a SQL boolean constraint and specify what happens when a record fails”
      ↩︎ The production-readiness checklist

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