What you will be able to do
- Match each file and table format to the reader and options that ingest it, for batch reads and streaming reads
- Choose between directory listing and file notification mode when Auto Loader watches a large, growing prefix
- Predict what an Auto Loader stream does when a new field shows up, under each cloudFiles.schemaEvolutionMode
- Load images and PDFs with the binaryFile source and use its metadata columns
Key concept
Format keyword plus reader options — Every ingestion read names a format keyword, such as delta, json, csv, binaryFile, kafka or cloudFiles. That keyword picks a reader with its own options, its own output columns and its own failure behaviour. Most ingestion bugs come from expecting one format's defaults to apply to another.
1.Table formats, columnar files and text files
The formats you ingest fall into three families, and the family tells you what the reader has to work out for itself. Table formats (Delta Lake and Iceberg) carry a transaction log and a schema, so a read gets a consistent snapshot with no guessing. Columnar files (Parquet, ORC) carry a schema in every file but no log that ties the files together. Text formats (JSON, CSV, XML, text) carry neither, so the reader has to infer types, find record boundaries and decide what to do with lines it cannot parse.
On Databricks the default format differs from open-source Spark. Delta Lake is what you get when you write a table without naming a format, while Apache Spark defaults to Parquet. So the bronze table you land data in is Delta unless you choose otherwise, whatever the source files were. Iceberg tables are read and written as tables, and Databricks interoperates with external Iceberg engines. You read them as tables rather than parsing their data files yourself.
| Format | Family | Reader options you will reach for |
|---|---|---|
| Delta Lake | Table format (ACID, schema evolution) | None needed for schema; the default format on Databricks |
| Iceberg | Table format | Read and write Iceberg tables; interoperate with external Iceberg engines |
| Parquet | Binary columnar | Schema is in the file; the Apache Spark default format |
| JSON | Human-readable text | Multiline records and schema inference |
| CSV | Human-readable text | Headers, delimiters and malformed records |
The text formats have the most options because they leave the most decisions to the reader. A JSON file that pretty-prints one object across many lines needs the multiline option, or every line is treated as a broken record. A CSV export with a header row and a semicolon delimiter needs both declared, or the header becomes a data row and every record collapses into a single column. Malformed-record handling decides whether a bad line is dropped, kept or fails the read.
Checkpoint 1 of 8· Check yourself
On Databricks, an engineer reads a folder of Parquet files and writes the result to a new bronze table without naming a format. What format is the bronze table?
On Databricks, Delta Lake is the default format for writing tables, whatever the source files were. Parquet is the default only in open-source Apache Spark.
“Databricks uses Delta Lake as the default protocol for reading and writing data and tables, whereas Apache Spark uses Parquet.”Source: docs.databricks.com
Sources1
2.Auto Loader formats versus streaming straight from a table
Auto Loader (cloudFiles) is the streaming source for files that arrive in a directory. What matters for format choice is its list: JSON, CSV, XML, PARQUET, AVRO, ORC, TEXT and BINARYFILE, including pre-compressed files. You set the format with cloudFiles.format, and the CSV header and delimiter, multiline JSON and binaryFile options are the same reader options described above. Delta and Iceberg are not on that list. They are tables with their own logs, so you stream them as tables instead of listing their data files.
A Delta table read as a stream has a time limit that file sources do not. The stream has to run at least once inside the source table's retention windows. By default that is 7 days for files removed by VACUUM and 30 days for the transaction log. A weekly job against a table vacuumed on the default schedule will eventually find its next file already deleted. The fix is to lengthen the source table's retention. It is not to tell Spark to ignore missing files.
(events.writeStream
.outputMode("append")
.option("checkpointLocation", "/tmp/delta/events/_checkpoints/")
.toTable("events")
)On the write side, the Delta transaction log gives exactly-once processing even when other streams or batch jobs write to the same table. Checkpoints can sit inside the table directory (for example <table-name>/_checkpoints) because VACUUM skips directories whose names begin with an underscore.
Checkpoint 2 of 8· Check yourself
A weekly streaming job reads from a Delta table that is vacuumed on the default schedule. One week the job fails because a data file it needs has already been deleted. What is the right fix?
A Delta streaming source has to run inside the source table's retention windows. If the schedule can't keep up, you lengthen the retention. Ignoring missing files silently produces incorrect results. Delta is not an Auto Loader format. Moving the checkpoint protects only the checkpoint, not the source data files.
“If a stream's schedule can't keep up with the default retention windows, increase the source table's retention instead.”Source: docs.databricks.com
Checkpoint 3 of 8· Fill the gap
This stream writes into the Delta table events, and its checkpoint lives in a _checkpoints directory that VACUUM skips. Which option name tells the writer where that checkpoint goes?
(events.writeStream
.outputMode("append")
.option(" ? ", "/tmp/delta/events/_checkpoints/")
.toTable("events")
)The checkpointLocation option points the stream at the directory where it keeps its progress. Here that is a _checkpoints folder under the table directory, which VACUUM leaves alone.
3.Finding new files in a prefix with millions of objects
How Auto Loader discovers new files matters as much as how it parses them. By default it uses directory listing: on each run it lists the input path and compares the result with what its checkpoint has already seen. That is cheap for a small landing folder. For an hour-partitioned S3 prefix that has grown to tens of millions of objects, every pass has to walk the whole tree before a new file can be picked up.
File notification mode stops listing altogether. Cloud storage sends an event for each new object to a queue, and Auto Loader reads the queue. You turn it on with cloudFiles.useNotifications. In classic notification mode Auto Loader creates a dedicated notification service and queue for each stream. With file events enabled on the external location, there is one queue and event subscription per location, and backfill is handled for you. Databricks recommends file notification mode with file events for most workloads.
Several tempting fixes still list the directory. A larger cloudFiles.maxFilesPerTrigger lets each batch take more files, but they are still found by listing. A shorter cloudFiles.backfillInterval schedules extra full sweeps, which adds listing rather than replacing it. Switching to a scheduled availableNow run also lists, only less often, and that works against a seconds-level SLA. One caveat for file events: the service caches recently created files. A stream that runs less than once every seven days loses that cache and falls back to listing.
Checkpoint 4 of 8· Check yourself
An Auto Loader stream reads an hour-partitioned S3 prefix that has grown to tens of millions of objects. New files now take minutes to be picked up because every run walks the whole tree. Which change stops the stream from listing the directory to find new files?
File notification mode reads storage events for new objects from a queue, so it skips directory listing entirely. A larger maxFilesPerTrigger, a shorter backfillInterval and availableNow runs all still find files by listing. The backfillInterval change actually adds more full sweeps.
“Auto Loader's file notification mode can help reduce your cloud costs further by avoiding directory listing altogether.”Source: docs.databricks.com
Checkpoint 5 of 8· Exam question
A team ingests clickstream JSON files that land continuously in a deeply nested, hour-partitioned S3 prefix, and the SLA requires new files to be picked up within seconds even as the prefix grows into tens of millions of objects. Which Auto Loader configuration change best meets this requirement?
Correct answer: A — Enable cloudFiles.useNotifications=true so Auto Loader discovers new files through cloud storage events delivered to a managed queue instead of repeatedly listing the prefix.
- A. Correct. Event-driven notification mode avoids repeatedly listing a prefix that has grown to tens of millions of objects, so new-file latency stays low and stable regardless of prefix size.
- B. Incorrect. Directory listing still has to enumerate the entire nested prefix on every trigger, so a larger per-trigger file cap does not fix the growing listing cost or the seconds-level latency requirement.
- C. Incorrect. Backfill is a periodic safety-net listing meant to catch files discovery missed, not the primary discovery path; running a full listing every minute against tens of millions of objects is expensive and still listing-based.
- D. Incorrect. Running only once per scheduled job trades away the continuous, low-latency discovery the SLA requires, since new files would wait for the next scheduled invocation instead of being picked up within seconds.
4.Schema hints, the rescued data column and new fields
Text formats need schema inference, and inference can be corrected with schema hints. When two Parquet files disagree on a column's type, Auto Loader picks the wider type. A hint overrides that choice. A hint does not cast the column: it tells the reader to read the column as the hinted type. Values that do not fit go to the rescued data column, _rescued_data. This is a JSON document holding the fields that did not match the schema, plus the source file path.
Under the default mode, the failure is deliberate. Before throwing, Auto Loader runs inference on the latest micro-batch and adds the new columns to the end of the schema in the schema location. Existing column types do not change. The next start reads that merged schema, and the new column is populated from then on. The stream does not heal itself mid-flight, which is why Databricks recommends running Auto Loader under Lakeflow Jobs set to restart automatically.
| Mode | Stream | Schema | Where the new field's data goes |
|---|---|---|---|
| addNewColumns (default) | Fails with UnknownFieldException; restart resumes | New columns merged at the end | Its own column, after restart |
| rescue | Never fails on schema changes | Never evolves | _rescued_data |
| failOnNewColumns | Fails and stays failed until the schema is updated or the offending file removed | Not updated automatically | Nowhere until you act |
| none | Keeps running | Not evolved | Ignored, unless rescuedDataColumn is set |
Pick the mode from what the table is for. Choose rescue when the bronze schema must stay fixed and nothing may be lost. Choose addNewColumns when downstream consumers want new fields as real columns and a restart is cheap. Choose none only when you truly do not care about new fields.
Checkpoint 6 of 8· Check yourself
Bronze ingestion uses a schema hint so that Auto Loader reads the amount column as an integer. Some incoming files contain amount values that do not fit an integer. What happens to those values?
A schema hint does not cast the column. It tells the reader to read the column as the hinted type. Values that don't fit are not lost: they go to the rescued data column along with the source file path.
“Auto Loader can detect schema drifts, notify you when schema changes happen, and rescue data that would have been otherwise ignored or lost.”Source: docs.databricks.com
Checkpoint 7 of 8· Exam question
A bronze-layer Auto Loader stream is defined without an explicit schema, so cloudFiles.schemaEvolutionMode defaults to addNewColumns. A new field starts appearing in the upstream JSON payload. What happens to the running stream?
Correct answer: A — The stream throws an UnknownFieldException and stops; once the orchestration layer restarts the job, the merged schema is picked up and the new column populates from that point onward.
- A. Correct. With
addNewColumns, Auto Loader intentionally fails the micro-batch with anUnknownFieldExceptionso the orchestrator restarts the stream with the evolved schema, after which new records populate the added column normally. - B. Incorrect. Schema changes under
addNewColumnsare not applied mid-batch without a restart; the stream must stop and relaunch with the updated schema definition before the new column is usable. - C. Incorrect. Silently dropping new fields describes the
noneevolution mode, not theaddNewColumnsdefault, which is designed to surface and incorporate new columns rather than discard them. - D. Incorrect. Routing unexpected fields into
_rescued_datawithout evolving the schema describes therescuemode, which is a different, explicitly opted-into behavior from theaddNewColumnsdefault.
Sources5
5.Images, audio and PDFs with binaryFile
Unstructured files are ingested with the binaryFile format, which turns each file into one row. You do not parse anything. The row carries path (string), modificationTime (timestamp), length (file size in bytes), content (the raw bytes as BinaryType), plus any partition columns. This is the format to use for images, audio or PDFs going to downstream processing or ML inference. In streaming it is the BINARYFILE format of Auto Loader.
df = spark.read.format("binaryFile").load("/Volumes/<catalog>/<schema>/<volume>/")
display(df)Two path options shape what gets loaded. pathGlobFilter (for example *.jpg) keeps only matching files and still keeps partition discovery. recursiveFileLookup searches nested directories and turns partition discovery off. Because content holds whole files, select only path, length and modificationTime when you just need an inventory. Save the loaded data to a Delta table so later reads are faster.
Checkpoint 8 of 8· Check yourself
Scanned PDF invoices keep arriving in a cloud storage folder. They need to be streamed into a bronze table as raw bytes plus path and size, so a later ML inference step can work on them. Which Auto Loader setting fits?
In Auto Loader, the binaryFile format turns each file into one row. That row holds path, modificationTime, length and the raw bytes in content, with no parsing. This is the format meant for images, audio and PDFs. Text parses files into string rows. Delta is not an Auto Loader format. Parquet expects files that are already columnar.
“Auto Loader can ingest JSON, CSV, XML, PARQUET, AVRO, ORC, TEXT, and BINARYFILE file formats.”Source: docs.databricks.com
Sources6
Sources
(6)
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/query/formatsOfficial docs
“Databricks uses Delta Lake as the default protocol for reading and writing data and tables, whereas Apache Spark uses Parquet.”
↩︎ Table formats, columnar files and text files“Read and write Iceberg tables and interoperate with external Iceberg engines.”
↩︎ Table formats, columnar files and text files“Read and write delimited text files, with options for headers, delimiters, and malformed records.”
↩︎ Table formats, columnar files and text files“Read and write JSON files, including options for multiline records and schema inference.”
↩︎ Table formats, columnar files and text files“Databricks has built-in keyword bindings for all of the data formats natively supported by Apache Spark.”
↩︎ Key concept - 2.
“Auto Loader can ingest JSON, CSV, XML, PARQUET, AVRO, ORC, TEXT, and BINARYFILE file formats.”
↩︎ Auto Loader formats versus streaming straight from a table“By default, Auto Loader uses directory listing mode. However, Databricks recommends file notification mode using file events for most workloads.”
↩︎ Finding new files in a prefix with millions of objects“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“Auto Loader can ingest JSON, CSV, XML, PARQUET, AVRO, ORC, TEXT, and BINARYFILE file formats.”
↩︎ Checkpoint - 3.
“If a query falls behind these windows, it fails with DELTA_FILE_NOT_FOUND_DETAILED and must be reset with a full refresh.”
↩︎ Auto Loader formats versus streaming straight from a table“Do not set spark.sql.files.ignoreMissingFiles to true as a workaround because this configuration silently produces incorrect results.”
↩︎ Exam trap 3“If a stream's schedule can't keep up with the default retention windows, increase the source table's retention instead.”
↩︎ Checkpoint - 4.https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/file-notification-modeOfficial docs
“In classic file notification mode, Auto Loader automatically sets up a dedicated notification service and queue for each stream.”
↩︎ Finding new files in a prefix with millions of objects“Databricks handles backfill automatically for external locations that are enabled for file events.”
↩︎ Finding new files in a prefix with millions of objects“If Auto Loader runs infrequently, this cache can expire, and Auto Loader falls back to directory listing to discover files and update the cache.”
↩︎ Finding new files in a prefix with millions of objects - 5.
“Auto Loader doesn't cast the column to the specified type, but rather tells the Parquet reader to read the column as the specified type.”
↩︎ Schema hints, the rescued data column and new fields“Restarting the stream resumes processing with the updated schema.”
↩︎ Schema hints, the rescued data column and new fields“Auto Loader never evolves the schema and the stream does not fail due to schema changes.”
↩︎ Schema hints, the rescued data column and new fields“When Auto Loader detects a new column, the stream stops with an UnknownFieldException.”
↩︎ Exam trap 1“When Auto Loader detects a new column, the stream stops with an UnknownFieldException.”
↩︎ Prediction - 6.
“reads binary files and converts each file into a single record containing the file's raw content and metadata”
↩︎ Images, audio and PDFs with binaryFile