Auto Loader, COPY INTO, and Lakeflow Connect
Choose between incremental file ingestion, a SQL load, and a managed connector. Handle new columns and recover a stopped stream.
Auto Loader
Auto Loader incrementally and efficiently processes new files as they arrive in cloud storage. It is a Structured Streaming source called cloudFiles. It remembers which files it has processed (in the checkpoint, using RocksDB), so each file is loaded exactly once, and it scales to millions of files.
(spark.readStream.format("cloudFiles")
.option("cloudFiles.format", "json") # json, csv, parquet, avro, orc, text, binaryFile, xml
.option("cloudFiles.schemaLocation", "/Volumes/main/chk/orders_schema") # where inferred schema is tracked
.option("cloudFiles.inferColumnTypes", "true") # otherwise JSON/CSV columns are strings
.option("cloudFiles.schemaEvolutionMode", "addNewColumns")
.load("/Volumes/main/raw/landing/orders/")
.select("*", F.col("_metadata.file_path").alias("source_file"),
F.current_timestamp().alias("ingested_at"))
.writeStream
.option("checkpointLocation", "/Volumes/main/chk/orders")
.option("mergeSchema", "true")
.trigger(availableNow=True) # incremental batch
.toTable("main.bronze.orders"))
In SQL (Databricks SQL and pipelines), the equivalent is a streaming table over STREAM read_files(...).
Supported sources and JSON layout
Supported sources: Amazon S3 (s3://), ADLS Gen2 (abfss://), Azure Blob Storage (wasbs://), Google Cloud Storage (gs://), and Unity Catalog volumes (/Volumes/...). The JSON format expects one object per line (JSON Lines) by default; add .option("multiLine", "true") for pretty-printed files.
New and existing files
On its first run Auto Loader processes the files already in the input directory as well as new ones (cloudFiles.includeExistingFiles defaults to true; set it to false to ingest only files that arrive after the stream starts). The option only has effect on the first run of a stream.
Schema inference and evolution
Without a provided schema, Auto Loader samples files (up to 50 GB or 1000 files) to infer it and stores it in cloudFiles.schemaLocation. By default JSON and CSV columns are inferred as strings unless inferColumnTypes is true. cloudFiles.schemaHints fixes types for specific columns.
You can also provide the schema yourself, and then nothing is inferred:
(spark.readStream.format("cloudFiles")
.option("cloudFiles.format", "json")
.schema("order_id BIGINT, price DOUBLE, in_stock BOOLEAN") # explicit schema: no inference
.load("s3://acme-landing/orders/"))
Python cloudFiles infers JSON and CSV columns as strings by default. Fix types with an explicit schema, cloudFiles.schemaHints, or cloudFiles.inferColumnTypes = true. cloudFiles.schemaLocation only stores and tracks the inferred schema, it does not change types. In SQL, read_files infers column types by default.
When the source later gains a column, the evolution mode decides what happens:
cloudFiles.schemaEvolutionMode | When a new column appears |
|---|---|
addNewColumns (default when no schema is provided) | The stream fails with an UnknownFieldException, the new column is added to the stored schema, and the stream works after a restart. Run it in a job with retries so restarts are automatic. |
rescue | Schema never evolves; new columns go into _rescued_data. Stream does not fail. |
failOnNewColumns | Stream fails and does not update the schema until you change it. |
none (default when a schema is provided) | New columns are ignored. Data is not rescued unless rescuedDataColumn is set. |
The _rescued_data column collects data that does not match the schema (wrong type, new column, case mismatch) as JSON, so nothing is silently lost. Schema enforcement on the target table still applies.
File detection modes
| Mode | How | Use when |
|---|---|---|
| Directory listing | Lists the input directory to find new files. No extra cloud setup. | Most cases; moderate file volumes |
File notification (cloudFiles.useNotifications = true) | Uses cloud events and queues (SNS/SQS, Event Grid, Pub/Sub) to learn about new files without listing. With Unity Catalog, managed file events on the external location set this up for you. | Very large directories, high file volumes, lower latency |
On Runtime 18.1 and later, Auto Loader can use managed file events automatically when the source location has file events enabled. Check the file events FAQ for runtime-specific behavior. Why file notification scales better: directory listing must list the whole input path on every micro-batch, which gets slower and costs more cloud API calls as the directory grows. File notification reads events from a queue instead, but needs cloud permissions to create the notification and queue resources (or managed file events on the external location).
Both modes work with any trigger, including batch-style availableNow runs.
COPY INTO
CREATE TABLE IF NOT EXISTS main.bronze.orders; -- schemaless placeholder is allowed
COPY INTO main.bronze.orders
FROM 's3://acme-landing/orders/'
FILEFORMAT = CSV
FORMAT_OPTIONS ('header' = 'true', 'inferSchema' = 'true')
COPY_OPTIONS ('mergeSchema' = 'true'); -- 'force' = 'true' reloads already-loaded files
- SQL command, idempotent: files already loaded are skipped on rerun.
- Re-scans the source directory each run; suited to thousands of files, not millions.
- Options:
PATTERN = '*.csv',FILES = ('a.csv','b.csv'),VALIDATE ALL(dry run). - Source can be a Unity Catalog volume or a cloud storage path governed by an external location. Put sample files in a volume rather than a workspace folder.
Auto Loader vs COPY INTO
| Auto Loader | COPY INTO | |
|---|---|---|
| Interface | Python / streaming tables in SQL | SQL command |
| Scale | Millions of files, efficient discovery | Thousands of files |
| Schema evolution | Rich (modes, rescued data, hints) | mergeSchema |
| Continuous / streaming | Yes | No, batch only |
| Recommendation | Default choice for file ingestion | Simple, ad hoc or SQL-only loads |
Lakeflow Connect New exam

Lakeflow Connect is Databricks' ingestion family. It has two kinds of connectors:
| Kind | What it is | Examples |
|---|---|---|
| Standard connectors | Building blocks you configure in your own pipeline or job code | Auto Loader and cloud storage, COPY INTO, Kafka, Kinesis, Event Hubs, Pub/Sub, Pulsar, SFTP, file upload |
| Managed connectors | Fully managed, point-and-click (or API/bundle) ingestion from enterprise apps and databases. Databricks handles authentication, incremental reads, CDC, schema changes and retries. Runs on serverless and lands data in Unity Catalog streaming tables. | SaaS: Salesforce, Workday, ServiceNow, Google Analytics, SharePoint, others. Databases: SQL Server, PostgreSQL, MySQL, Oracle and more. |
How a managed connector is set up
- Create a Unity Catalog connection holding the source credentials (needs
CREATE CONNECTION). - Create an ingestion pipeline in the UI ("Data ingestion" page), with an API, or in a bundle. Pick source objects (tables, reports) and a destination catalog and schema.
- Database connectors also need an ingestion gateway: a pipeline on classic compute that reads the change log (CDC) continuously and stages changes in a volume. The ingestion pipeline (serverless) applies them to the destination tables.
- Schedule the ingestion pipeline with a Lakeflow Job, or a schedule on the pipeline.
Destination tables are streaming tables; SCD Type 1 (default) or Type 2 history can be configured. Nested and semi-structured fields from SaaS APIs (JSON objects, arrays) land as structs, arrays, or strings that you parse in silver.
Other ingestion paths
- Partner Connect / partner tools (Fivetran, Qlik, others) for sources without a native connector.
- JDBC/ODBC or REST in notebooks, scheduled by Lakeflow Jobs, landing data in volumes or directly in tables.
- Lakehouse Federation: query an external database in place through a foreign catalog, without copying data.
- File upload UI for small local files.
Choosing an ingestion method
| Situation | Choose |
|---|---|
| Files landing in cloud storage, growing to millions, need schema evolution | Auto Loader |
| SQL-only team, a few thousand files, idempotent loads | COPY INTO |
| Salesforce, Workday, ServiceNow, or CDC from SQL Server, with minimal code and maintenance | Lakeflow Connect managed connector |
| Kafka or other event bus with low latency | Structured Streaming / streaming table (standard connector) |
| Source has no native connector but a partner has one | Partner connector (Partner Connect) |
| Custom API with paging and auth logic | Python in a notebook, scheduled by Lakeflow Jobs, land then Auto Loader |
| Occasional analysis of operational data without copying | Lakehouse Federation |
| A one-off CSV from your laptop | UI upload |
Data volume, ingestion frequency, data types (structured vs semi- vs unstructured), and governance needs in Unity Catalog. Managed connectors and Auto Loader both land in Unity Catalog-governed tables; a managed connector removes custom code and maintenance.
Handle a new field
A JSON source acquires a field called currency. You run Auto Loader with addNewColumns and a persisted schema location. Describe the first failure and the next run.
Check your reasoning
Discovery records the evolved schema and interrupts the stream. Restart it with the same schema and checkpoint locations to process the batch using the new column.
Product reference
Auto Loader, COPY INTO, and Lakeflow Connect quiz
Answer 9 questions. Check each answer for an explanation.