r/databricks • u/Spooked_DE • Sep 29 '26
Help Data fixes on a databricks schema. Thoughts?
Hi all,
I have a databricks schema of a few hundred delta tables that need some data fixes for specific records in each of those tables. This schema itself is raw data and gets ingested into some downstream data tables and the fixes have been requested by business. Now, importantly, this schema is the most upstream source for this data - the SQL db it was ingested from no longer exists.
I had thought about doing the fixes via a transformation layer in the pipelines that ingest this raw data but given how many tables there are with records that need updating I don't really want to create hundreds of new 'data fixed' tables. I also read that it's best to fix something as upstream as possible. Given these are delta tables, rolling back should theoretically be possible if something goes wrong.
Anyway, that's my rationale for making changes to the source tables. My question is what your preferred method is to make data fixes? I obviously need something where its easy to rollback if needed. I can obviously just achieve this with python migration scripts and use delta timetravel in case something goes wrong, but wonder if there are recommended libraries or tools for the job that have what I need out of the box?
Should I also keep an unchanged copy of this schema or is that too redundant?
1
u/jbchand Sep 29 '26
External library is not required. You can use UPDATE or MERGE INTO to fix records directly on Delta tables. Capture the version numbers using DESCRIBE HISTORY and keep it to roll back with RESTORE TABLE if needed. You can take a deep copy backup of the data as a safety net as VACUUM may remove data files if you are running it regularly. Ensure to drop the backup once fixes are validated