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.
| Choice | When the sources recommend it |
|---|---|
| Triggered pipeline | Default for the vast majority of pipelines; scheduled through the job scheduler or a Lakeflow Job |
| Continuous pipeline | Genuine sub-minute latency needs; requires an always-on cluster |
| Lakeflow Job with Trigger.AvailableNow | No 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?
Correct answer: A — Set `cloudFiles.useNotifications` to `true` so Auto Loader subscribes to cloud storage events and only processes files that a notification identifies, instead of repeatedly listing the bucket.
- A. Enabling notification mode makes Auto Loader consume cloud storage events from the SNS/SQS resources it provisions instead of polling the bucket, which cuts `LIST` calls sharply for files scattered across many prefixes while keeping discovery near real time.
- B. This still relies on directory listing, so the total number of `LIST` calls against the bucket is unchanged; it only changes how many files each micro-batch pulls per listing, not the discovery cost itself.
- C. Skipping existing files on restart only affects the initial backfill and does not stop the ongoing directory listing that discovers each new hour's files, so the recurring `LIST` cost remains.
- D. `Trigger.AvailableNow` changes how often the stream runs, not the discovery mechanism, and directory listing still issues fresh `LIST` calls against the bucket on each run rather than reusing a cached listing.
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?
With no low-latency requirement, an AvailableNow batch job avoids always-on compute, and a file arrival trigger lowers the delay after a file lands. Continuous mode and ProcessingTime triggers both keep compute running.
“These batch jobs can be triggered using file arrival triggers to further lower the latency between file arrival and processing.”Source: docs.databricks.com
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:
| Mode | Characteristics | Use when |
|---|---|---|
| Directory listing | Default; lists storage to find new files | You can't use file events; pair with cloudFiles.cleanSource to keep listings small |
| File events | One queue per bucket; incremental discovery on subsequent runs | Low latency and simplicity; recommended for most workloads |
| Classic file notification | Reads directly from the cloud queue, without the extra caching hop of file events; supports resource tags | Very 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:
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")
)availableNow=True processes everything available and then stops. That is the Trigger.AvailableNow batch pattern Databricks recommends when cost matters more than latency.
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?
The source and the move destination must be in the same external location, volume or DBFS mount. A cross-bucket move raises an error.
“Cross-bucket and cross-container moves are not supported and result in an error.”Source: docs.databricks.com
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:
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.
{
"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)
Correct answers: A, B — `silver_customers` will contain multiple rows per `customer_id`, each representing a distinct historical version of that customer's attributes over time.; If `silver_customers`'s schema is pre-defined rather than inferred, it must include `__START_AT` and `__END_AT` columns typed to match the `sequence_num` column in `SEQUENCE BY`.
- A. SCD Type 2 storage preserves history by keeping one row per version of a customer's attributes rather than overwriting the previous row, so the target table grows a new row for each tracked change.
- B. When the target schema is defined ahead of time, AUTO CDC requires `__START_AT` and `__END_AT` columns typed to match the sequencing column so it can record each version's validity window correctly.
- C. Under SCD Type 2, a delete event closes out the current row's validity window by setting `__END_AT` rather than purging the row, so the customer's prior history including the delete remains queryable.
- D. AUTO CDC uses the sequence column to reconstruct the correct chronological order of events and update history accordingly; it does not simply throw away events that happen to arrive late.
- E. `KEYS` and `SEQUENCE BY` are required clauses that must be specified explicitly in every `AUTO CDC INTO` statement regardless of the storage mode; they are never inferred from source metadata.
- F. `AUTO CDC INTO` reads from any streaming table exposed to the pipeline, and that streaming table's own ingestion flow can originate from Kafka or another message bus, not only from Delta storage.
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?
Neither discovery mode guarantees order. The fix is to keep tombstones longer than the maximum delay, and the two-day default is too short here.
“Set the pipelines.cdc.tombstoneGCThresholdInSeconds table property on the target streaming table”Source: docs.databricks.com
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:
| Dimension | Checklist item |
|---|---|
| Data quality | Every dataset that can receive bad data has expect, expect_or_drop or expect_or_fail, chosen deliberately per constraint |
| Reliability | Scheduled through a Lakeflow Job; failure notifications configured; checkpoint-failure recovery tested |
| Reliability | Spark errors surface, so there are no broad try/except blocks catching AnalysisException |
| Observability | Event log queried; system.lakeflow.pipelines checked; update duration trend known |
| Deployment | Defined and deployed through a bundle with dev and prod targets; paths and catalogs parameterized |
| Cost and governance | Serverless 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?
The checklist says to let Spark errors surface. Catching them masks real errors and can interfere with the pipeline's normal retry and recovery behaviour.
“you don't wrap transformations in broad try/except blocks that catch AnalysisException or other internal Spark exceptions.”Source: docs.databricks.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
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.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.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.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.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.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.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.https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/productionOfficial docs
“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.
“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.
“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.https://docs.databricks.com/aws/en/ldp/conceptsOfficial docs
“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