A data engineer runs the Auto Loader stream shown in the exhibit. The stream does not set cloudFiles.schemaEvolutionMode. Its tracked schema and target table do not contain phone_number. A source system will soon start sending this new field.
Requirements:
phone_numbermust be added to the schema that Auto Loader tracks in its schema location.- No one may write or edit column definitions by hand.
- Ingestion must continue to use this incremental Auto Loader stream; restarting the stream is acceptable.
(spark.readStream .format("cloudFiles") .option("cloudFiles.format", "json") .option("cloudFiles.schemaLocation", "/Volumes/sales/bronze/landing/_schema") .load("/Volumes/sales/bronze/landing/customers/") .writeStream .option("mergeSchema", "true") .option("checkpointLocation", "/Volumes/sales/bronze/landing/_checkpoint") .toTable("sales.bronze.customers"))
Which approach should the engineer use to handle the upcoming field?
The reader uses the default addNewColumns mode because neither an explicit schema nor an evolution mode is supplied. Auto Loader updates its tracked schema when it detects the new field, then stops; restarting resumes processing with that schema. The writer's mergeSchema option allows the Delta target to accept the added column. Rescue does not evolve the tracked schema, failOnNewColumns requires manual intervention, and a batch replacement violates the streaming requirement.
- Not correct: Configure
cloudFiles.schemaEvolutionModeasfailOnNewColumnsbefore the new field arrives. This mode stops on a new field without automatically updating the schema. Meeting the requirement to add phone_number would require a manual schema update. - Not correct: Configure
cloudFiles.schemaEvolutionModeasrescuebefore the new field arrives. Rescue mode preserves unexpected field values separately without evolving the tracked schema, so phone_number would not become a tracked column. - Correct: Keep the current configuration and restart the stream after it stops on the new field. Without an explicitly supplied schema or evolution mode, Auto Loader uses addNewColumns. It automatically updates its tracked schema before stopping, and restarting resumes processing. The mergeSchema write option permits the target table to accept the new column.
- Not correct: Replace the stream with a batch append that sets
mergeSchematotrue. A mergeSchema batch append can add new columns to a table, but it replaces the Auto Loader stream, which the requirements do not allow.