Detect, validate, migrate, and analyze schema changes across Delta Lake tables β safely and automatically.
By Datanest Digital | Version 2.0.0 | $39
A complete toolkit for managing schema evolution in Databricks / Delta Lake pipelines:
schema-evolution-toolkit/
βββ README.md
βββ manifest.json
βββ LICENSE
βββ src/
β βββ schema_detector.py # Detect schema drift between expected and actual
β βββ schema_diff.py # Field-level diff with severity classification
β βββ schema_migrator.py # Apply safe migrations with rollback support
β βββ migration_generator.py # Generate SQL/Python migration scripts from diffs
β βββ impact_analyzer.py # Analyze downstream impact of schema changes
β βββ compatibility_checker.py # Backward/forward compatibility validation
β βββ schema_registry.py # Delta-table-backed schema version registry
β βββ schema_validator.py # Runtime DataFrame schema validation
βββ configs/
β βββ schema_policy.yaml # Evolution rules and policies per layer
β βββ schemas/
β βββ v1_customer.json # Customer schema v1 (4 fields)
β βββ v2_customer.json # Customer schema v2 (rename, add nested struct)
β βββ v3_customer.json # Customer schema v3 (arrays, nested structs, new fields)
β βββ v1_order.json # Order schema v1 (7 fields)
β βββ v2_order.json # Order schema v2 (type widening, shipping, discounts)
βββ notebooks/
β βββ detect_drift.py # Interactive drift detection notebook
β βββ evolve_schema.py # Interactive schema migration notebook
β βββ generate_migration.py # Migration script generation notebook
βββ tests/
β βββ conftest.py # Shared pytest fixtures (SparkSession, sample schemas)
β βββ test_schema_detector.py # Detector unit tests
β βββ test_compatibility.py # Compatibility checker tests
β βββ test_schema_diff.py # Schema diff tests
β βββ test_migration_generator.py # Migration generator tests
β βββ test_impact_analyzer.py # Impact analyzer tests
βββ guides/
βββ schema-evolution-strategy.md # Versioning, migration & impact analysis guide
ββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Upstream ββββββΆβ Schema Detector ββββββΆβ Drift Report β
β Data Source β ββββββββββββββββββββ ββββββββββ¬βββββββββ
ββββββββββββββββ β
βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β Schema Diff βββββββ Compare v1/v2 β
β (field-level) β βββββββββββββββββββ
βββββββββ¬βββββββββββ
β
ββββββββββββββΌβββββββββββββββββ
βΌ β βΌ
ββββββββββββββββββ β βββββββββββββββββββββ
β Compatibility β β β Impact Analyzer β
β Checker β β β (downstream deps) β
βββββββββ¬βββββββββ β βββββββββ¬ββββββββββββ
β β β
Compatible? βββββββΌββββββ Risk
βββββββββββ β Migration β Score OK?
βΌ YES βΌ NO β Generator β βββββββββ
ββββββββββββ ββββββββ βββββββ¬ββββββ βΌ YES βΌ NO
β Generate β βAlert/β β ββββββββββββ βββββββββββ
β Scripts β βBlock β β β Apply β β Manual β
βββββββ¬βββββ ββββββββ β β Scripts β β Review β
β β βββββββ¬βββββ βββββββββββ
βΌ β β
ββββββββββββββββ β β
β Schema ββββββββββββββββββββββββββββ
β Registry β
β (store ver.) β
ββββββββββββββββ
Follow this guide to get schema evolution toolkit up and running in your environment.
from schema_detector import SchemaDetector
detector = SchemaDetector(spark)
# Compare a live table against an expected JSON schema
report = detector.compare_table_to_schema(
table_name="catalog.bronze.customers",
expected_schema_path="/Volumes/schemas/v2_customer.json",
)
print(report.summary())
# SchemaReport: 2 added columns, 1 type change, 0 removed columnsfrom schema_diff import SchemaDiff
differ = SchemaDiff()
diff = differ.diff_from_files("v1_customer.json", "v2_customer.json")
# Print a categorized report
print(diff.to_text())
# Get Markdown for PR comments
print(diff.to_markdown())
# Check for breaking changes
if diff.has_breaking_changes:
for bc in diff.breaking_changes:
print(f" BREAKING: {bc.field_path} β {bc.message}")from compatibility_checker import CompatibilityChecker
checker = CompatibilityChecker()
result = checker.check_backward_compatible(old_schema, new_schema)
if not result.is_compatible:
for issue in result.issues:
print(f" BREAKING: {issue}")from migration_generator import MigrationGenerator
gen = MigrationGenerator()
migration = gen.generate_from_files(
"v1_customer.json", "v2_customer.json",
table_name="catalog.silver.customers",
)
# Print forward SQL
print(migration.render_forward_sql())
# Print rollback SQL
print(migration.render_rollback_sql())
# Generate a Python migration module
print(migration.render_python_migration())
# Get structured JSON for CI/CD
print(migration.to_json())from impact_analyzer import ImpactAnalyzer
analyzer = ImpactAnalyzer()
analyzer.load_manifest_file("dependency_manifest.json")
impact = analyzer.analyze_from_diff(diff, "catalog.silver.customers")
print(impact.summary())
# Impact Analysis: 3/5 assets impacted, risk_score=0.45, critical=1
if impact.critical_impacts:
print("BLOCKED: SLA-critical assets affected!")from schema_migrator import SchemaMigrator
migrator = SchemaMigrator(spark)
migrator.add_columns(
table_name="catalog.silver.customers",
columns={"loyalty_tier": "STRING", "last_login": "TIMESTAMP"},
)from schema_registry import SchemaRegistry
registry = SchemaRegistry(spark, registry_table="catalog.meta.schema_registry")
registry.register(
subject="customers",
version=2,
schema=new_schema,
description="Added loyalty_tier and last_login columns",
)from schema_validator import SchemaValidator
validator = SchemaValidator(spark)
result = validator.validate(df, expected_schema, mode="strict")
if not result.is_valid:
raise ValueError(f"Schema validation failed: {result.errors}")The toolkit includes example schemas demonstrating common evolution patterns:
| Version | Fields | Changes |
|---|---|---|
| v1 | id, name, email, created_at | Initial schema |
| v2 | id, name, contact_email, phone, address (struct), created_at | Rename email, add phone + nested address |
| v3 | All v2 + preferences (struct with array), tags (array), loyalty_points, updated_at, address.region | Complex nested types, arrays |
| Version | Fields | Changes |
|---|---|---|
| v1 | order_id, customer_id, order_date (date), status, total_amount, item_count, created_at | Initial schema |
| v2 | All v1 + currency, shipping_address (struct), discount_code, discount_amount, updated_at | Type widening (dateβtimestamp), multi-currency, discounts |
delta-spark)Get the full Schema Evolution Toolkit and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.