Question 1easy#Scenario Based#Azure Data Factory
A pipeline copies data from Blob Storage to Azure SQL Database. If the source file schema changes (e.g., a new column is added), how can ADF handle this without manual intervention?
Say your answer out loud first, the way you would in the room.
In shortThe Copy activity alone won't add a new column to an existing Azure SQL table: it maps columns by name, and an existing sink table must already contain every column being copied.
The Copy activity alone won't add a new column to an existing Azure SQL table: it maps columns by name, and an existing sink table must already contain every column being copied. To handle new columns automatically, use one of these:
- Mapping data flow with schema drift. Turn on Allow schema drift on the source and the sink, with auto-mapping on, so new columns flow through. Set the SQL sink's table action to Recreate if the table may be rebuilt from the incoming schema, or write to a staging table instead.
- Stage, then alter. Copy the file into a staging table created fresh each run (
tableOption: autoCreateon a new table name), then run a stored procedure that compares the staging columns with the target (INFORMATION_SCHEMA.COLUMNS), adds missing ones withALTER TABLE ... ADD, and inserts the rows. - Keep extra fields as JSON. Load known columns into typed columns and the rest into one
NVARCHAR(MAX)JSON column, so new fields never break the load.
Whichever you choose, log or alert when the schema changes, so a renamed column isn't silently treated as new.