Data Engineer Associate · Domain 2: Data Ingestion and Loading · 21% of the exam
Task 2.3: Use Auto Loader with schema enforcement and schema evolution in batch modes (for example, directory listing or file notification) to land data into Unity Catalog–governed tables.
The cloudFiles source, schema location, inference and hints, the schema evolution modes and the rescued data column, directory listing versus file notification with file events, and availableNow runs.
Study it
Auto Loader: schema inference, evolution modes and the rescued data column
Lesson coming
Auto Loader: directory listing, file notification and file events
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.
Question 1 · choose 1
An Auto Loader stream reads JSON with cloudFiles.schemaLocation set and no schema provided. The source starts sending a new field, and the stream stops with an UnknownFieldException. The team wants the new column added and ingestion to continue without manual work in the future. What should the data engineer do?
ARun the stream as a job task with retries so it restarts on the new schema
BSet cloudFiles.schemaEvolutionMode to failOnNewColumns
CDelete the checkpoint and schema location directories, then restart the stream
DSet cloudFiles.schemaEvolutionMode to none
Show the answer and why
ARun the stream as a job task with retries so it restarts on the new schema
Correct
In the default addNewColumns mode Auto Loader merges the new column into the schema location before failing; a restart resumes with the updated schema, so automatic restarts keep it running.
BSet cloudFiles.schemaEvolutionMode to failOnNewColumns
Incorrect
failOnNewColumns stops the stream and does not update the schema, so it needs manual intervention on every new field.
CDelete the checkpoint and schema location directories, then restart the stream
Incorrect
Removing the checkpoint loses the record of processed files, so files are read again and duplicated.
DSet cloudFiles.schemaEvolutionMode to none
Incorrect
In none mode new columns are ignored and not rescued unless rescuedDataColumn is set, so the field would never become a column.
With addNewColumns, the default when no schema is given, the failure is the expected signal that the schema has grown. Databricks recommends running such streams in Lakeflow Jobs so they restart automatically.
An Auto Loader stream in directory listing mode reads from an external location that receives millions of new files a day, and file discovery has become slow and expensive. Following Databricks recommendations, what should the data engineer change?
AEnable file events on the location and set cloudFiles.useManagedFileEvents
BSet cloudFiles.backfillInterval to one day on the existing stream
CIncrease cloudFiles.maxFilesPerTrigger on the existing stream
DReplace the stream with a COPY INTO statement scheduled at five-minute intervals
Show the answer and why
AEnable file events on the location and set cloudFiles.useManagedFileEvents
Correct
File notification mode with file events is more performant and scalable than listing, and Databricks recommends migrating directory listing streams to it.
BSet cloudFiles.backfillInterval to one day on the existing stream
Incorrect
A backfill interval schedules periodic full listings to catch missed files; it adds listing work rather than replacing it.
CIncrease cloudFiles.maxFilesPerTrigger on the existing stream
Incorrect
This caps how many files each micro-batch processes; it does not change how new files are discovered.
DReplace the stream with a COPY INTO statement scheduled at five-minute intervals
Incorrect
COPY INTO also has to work out which files in the directory are new, so the discovery cost stays; the change is to stop listing, not to swap the loading command.
Directory listing is the default and needs only read access, but its cost grows with the listing. File notification mode with file events uses cloud change notifications through one queue per external location.
An Auto Loader stream must keep running when the source adds new fields. New fields must not become table columns, but their values must be kept for later inspection. Which cloudFiles.schemaEvolutionMode meets this?
AaddNewColumns
Bnone
CfailOnNewColumns
Drescue
Show the answer and why
AaddNewColumns
Incorrect
In this mode new fields are added to the table schema as columns, which the requirement rules out.
Bnone
Incorrect
In none mode new columns are ignored, and their data is not kept unless a rescued data column is set separately.
CfailOnNewColumns
Incorrect
In this mode the stream fails and does not restart until the schema or the offending file is fixed.
Drescue
Correct
In rescue mode the schema never evolves and the stream does not fail; new columns are recorded in the rescued data column.
Schema evolution modes trade stream stability against schema changes. rescue keeps the schema fixed and puts unexpected data into _rescued_data as JSON.
Auto Loader infers a JSON source's schema, and every field arrives as a string. Two fields must be typed, event_ts as TIMESTAMP and amount as DOUBLE, while every other field keeps being inferred and new fields can still be added. Which option should be set?
Auto Loader infers every column of a JSON source as STRING. The team wants it to pick column types from the sampled data instead, the way the DataFrame JSON reader does. Which option should they set?
AcloudFiles.useStrictGlobber set to true
BcloudFiles.schemaLocation set to a new directory
CcloudFiles.inferColumnTypes set to true
DcloudFiles.maxFilesPerTrigger set to 1000
Show the answer and why
AcloudFiles.useStrictGlobber set to true
Incorrect
This changes how glob patterns match file paths; it does not affect type inference.
BcloudFiles.schemaLocation set to a new directory
Incorrect
The schema location stores the inferred schema over time; moving it does not change how types are inferred.
CcloudFiles.inferColumnTypes set to true
Correct
For formats that do not encode types, such as JSON, CSV and XML, this makes Auto Loader infer column types from the sample instead of using strings.
DcloudFiles.maxFilesPerTrigger set to 1000
Incorrect
This caps how many new files each micro-batch processes; it does not affect type inference.
Auto Loader infers JSON, CSV and XML columns as strings by default to avoid type mismatches during evolution. inferColumnTypes turns on type inference.
An Auto Loader stream runs as a scheduled job task on serverless compute each hour. Each run must process every file that has arrived since the last run and then stop. Which write configuration does this?
Continuous processing keeps running and is not supported on serverless compute.
D.writeStream.option("checkpointLocation", cp).toTable("main.bronze.events") with no trigger
Incorrect
Without a trigger, Spark uses a processing-time trigger of 0 seconds, so the query keeps running; on serverless it is rejected.
Scheduled incremental batches use Auto Loader with availableNow: the checkpoint remembers what was processed, and each run drains the backlog and ends.