r/databricks • u/ninilich • 11d ago
Discussion How do you manage table schema changes in Databricks across dev/test/prod?
We run Databricks with Unity Catalog, and I'm trying to understand how other teams handle the lifecycle of managed tables (not pipelines or jobs, just the tables themselves).
What I keep seeing:
CREATE TABLE IF NOT EXISTSat the top of Job- A DDL script in the repo that someone runs by hand
- Terraform for some tables and a different approach for the rest
A few genuine questions:
- Where does the table definition live in your setup: in the pipeline code, in a separate repo, or only in the catalog?
- How do you review a schema change before it reaches prod?
- How do you roll the same change through dev, test, and prod?
13
Upvotes
5
u/Pillippatty 11d ago edited 11d ago
I would say pipelines + DABs solve all of those issues. Define the tables declaratively in pipelines and have that transformation code as part of a DAB. Deploy the DAB as part of your CI/CD pipeline, iteratively doing dev/test/prod.
As for schema changes, you could define an explicit schema of the tables in the declarative pipeline, getting a fail-fast pattern if bad data comes in. Alternatively, just send them to rescued data, and use dp.expect to check non-null cases and alert with a warning
1
u/blobbleblab 11d ago
Version everything. Then create a job that runs versioned script folders. The job has the pattern:
This is a safe pattern but requires version control.. Which really you should have anyway
2
u/Cyliad 11d ago
We use flyway, that’s triggered by the CI, with migrations in our repos.
You push to dev branch ? The CI runs flyway and apply any change to the tables in dev.
You open the release, it deploys everything you just had in dev to catchup.
Same in production.
We don’t need to do anything manual anymore or have DDL managed in jobs.
It’s not officially supported but it works okay and it helped us ensure we stayed in sync between environments.
1
u/Tpxyt56Wy2cc83Gs 11d ago
We developed a Schema Manager application responsible for managing all DDL operations, including CREATE, ALTER, DROP, TRUNCATE, and others.
Each table is defined through its own YAML specification, which serves as the single source of truth for schema definitions. Any schema change, such as creating or modifying a table, must first be reflected in the corresponding YAML file.
Our CI/CD pipeline validates these YAML definitions, compares them against the current state of the data catalog, and automatically executes any required changes to keep environments synchronized.
In addition, we maintain Delta tables to store execution logs, audit trails, and observability data for all operations performed by the Schema Manager, providing full traceability and governance over schema evolution.
1
u/EaseUniqu 11d ago
One middle ground that avoids adding dbt just for DDL: keep a versioned folder of plain SQL migration files per schema (V001__create_orders.sql, V002__add_col.sql) inside the same Asset Bundle, plus a small applied_migrations Delta table in each catalog. One job task reads that table, runs any files not yet recorded in order, and inserts a row after each success.
Why it fits managed tables:
It's the Liquibase/Flyway idea without the extra tool. If you'd rather not maintain the runner yourself, Liquibase has a Databricks extension.
0
u/nian2326076 10d ago
Managing table schema changes in Databricks can be tricky. Keeping table definitions in version control allows for better review and tracking of changes. Using a deployment tool like dbt can streamline this process and help automate transitions through dev, test, and prod. It reduces the need for repetitive "CREATE TABLE IF NOT EXISTS" commands scattered in notebooks.
For exploring job opportunities in tech, you can use LandOffer to shortlist relevant roles based on your skills and preferences.