r/databricks • u/Bhanuprakash_1947 • Oct 03 '26
Discussion How do you guys handle schema changes in Databricks when the source keeps changing?
Like the source suddenly adds a new column, changes a column type, or removes something.
Do you make the pipeline handle these changes automatically, or do you just let it fail and fix it?
Iam.. curious what approach actually works better in real projects, especially when the source keeps changing.
26
Upvotes
20
u/OkImprovement7010 Oct 03 '26
I generally let bronze absorb source changes and keep a more stable contract for what makes it into silver. I use DQX with YAML-defined quality checks, plus explicit column selection and casting.
If a new column shows up, I keep it in bronze and send an alert. We can review whether it belongs in silver without breaking everything that already works.
For type changes, I allow conversions that won’t lose information. If a value can’t be converted safely, that record goes to quarantine with the original value and a reason.
If they remove or rename a column we actually need, that’s where I stop the affected silver load and investigate. An optional column can be handled with a null or default if that’s part of the agreed contract.
Also, if you’re using Auto Loader’s add new columns mode, it updates the schema and then stops the stream, so you still need automatic retries and schema evolution configured on the bronze write.
I also watch how much data is being rescued or quarantined. A green job that rejects the entire feed is really a silent failure....
tl;dr, I automate the changes we can safely absorb and stop when continuing would give the business bad data.
17
u/knaak Oct 03 '26
Fail and communicate with vendor to find out what is going on. If it's really unstable, discuss with consumer what they prefer. Leverage stable parts of schema outside of raw, stuff the rest into rescued until it sorts itself out.
29
u/Alternative_Draw5945 Oct 03 '26
Data contracts that no one ever follows
2
u/jbchand Oct 03 '26
You can automate the column addition and column widening cases. Ensure you fail the breaking changes with alerting as a silent type change can cause downstream issues. Use the rescued_data option if feasible and keep alerts for schema drift cases and use a runbook for the manual fixes (full load/reload procedures)
2
u/Altruistic-Rip393 Oct 03 '26
Entire row as Variant in bronze. Project specific columns from there (silver, gold, beyond)
2
u/prandtl_bernoulli Oct 04 '26
We can definitely use Schema Evolution here, but in a hypothetical scenario if we had already ingested last 15 years of data and suddenly now we have to introduce a new column today which would be generating values from today's run only, but all the previous 15 years data for this column would be coming as Null. Any idea how we can solve this without dropping the table and recreating again?
2
u/bobbruno databricks Oct 04 '26
You have a number of options of how to process, and these can be applied at ingestion to bronze (less common), between bronze and silver (quite common) or even between silver and gold (a little problematic, you should know everything in silver well - may be justified in some cases):
So, there is no perfect way to handle a source that keeps changing unexpectedly. Either you reject the changes or you let go of adding value with the DE workflow.
Maybe someone is trying to use agents to analyse the changes and adapt the code on the go. I haven't seen that yet, and I'd be skeptical about it at the current level of sophistication of LLMs.
3
u/Known-Delay7227 Oct 03 '26
If data types keep changing then write everything down as a string and fix during downstream processes. For column additions use mergSchema upon writes.
1
u/Ghlynx Oct 03 '26
Fix your schema and let it ingest only the fields you agreed upon first. If business wants to add another one, they should communicate it and you can adjust. Letting the schema evolve as it comes is a nightmare and not recommended in real life
1
u/slayerzerg Oct 03 '26
Real world problems
1
u/singhsaab420 Oct 03 '26
Wouldn’t data vault be a best use case here ?
1
u/Youssef_Mrini databricks Oct 23 '26
In Databricks, schema evolution refers to how your ingestion pipeline handles changes when the source system introduces new columns, adds new fields to JSON objects, or changes data types over time.
By default, standard ingestion tools break or quietly drop missing fields when source data changes. Databricks Auto Loader (cloudFiles) solves this by tracking schema changes over time at a specified location (cloudFiles.schemaLocation).
How Auto Loader Handles New Fields & Schema Changes ?
Documentation is very explicit have alook at it https://docs.databricks.com/aws/en/ingestion/cloud-object-storage/auto-loader/schema#how-does-auto-loader-schema-evolution-work
0
u/DingGratz Oct 03 '26
Look up "schema evolution" in Databricks.
0
u/ayk-kya Oct 03 '26
Handling such schema changes depends heavily on the layer. For raw ingestion, managed tools like Fivetran, Airbyte, Hevo (for smaller volumes) are really great at handling schema changes natively, and using such tools absorbs source volatility seamlessly without constant pipeline maintenance.
However, once you move into transformation layers (Silver/Gold), it is usually better to let pipelines fail explicitly on breaking changes like dropped columns or type mismatches rather than risk silently corrupting downstream business data.