CDC Lakehouse Medallion Pipeline Submission - Sagar Bala - #12
Open
sagarbalaai-code wants to merge 1 commit into
Open
CDC Lakehouse Medallion Pipeline Submission - Sagar Bala#12sagarbalaai-code wants to merge 1 commit into
sagarbalaai-code wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Submission Notes: CDC Medallion Lakehouse Pipeline
Hey Team,
Here is my submission for the CDC reliability assignment. I chose to model the E-Commerce domain (customers, orders, line items, and payment attempts) since it resembles the transactional systems I work with on a daily basis.
My Tech Stack & Approach
Since my core skillset is focused on the Databricks and Delta Lakehouse ecosystem (Python, SQL, PySpark, Auto Loader, and Delta Tables), I modeled the pipeline as a classic Medallion Architecture (Bronze → Silver → Gold). This allowed me to leverage Delta's native transaction logs and Change Data Feed (CDF) to build a reliable, incremental replication pipeline without writing heavy, custom state-tracking code.
Folder & Notebook Structure
All submission files are organized inside the
submission/sagarbalaai-code/directory:source/source_db.sql: The upstream transactional relational DDL schema (with indexes, keys, check constraints) and seed records representing our source data of record.pipeline/01_bronze_ingestion.py: Streams raw CDC events, runs schema drift checks, and appends to Bronze.pipeline/02_silver_merge.py: Reads the Bronze CDF incrementally and executes a deduplicated Delta MERGE.pipeline/03_gold_metrics.py: Combines Silver dimensions and facts to output business aggregates.tests/04_data_quality.py: Runs validation checks (system and business rules) to guarantee parity.Core Technical Solutions & Code Design
1. Ingestion & Schema Drift ("Stop-the-Line")
01_bronze_ingestion.pycheck_schema_compatibilitycompares incoming batch structures against the target table. If columns were dropped or datatypes were changed incompatibly, the code raises an exception and halts the write. This prevents corrupt data from contaminating the lakehouse.delta.enableChangeDataFeed = true) to enable incremental downstream syncs.2. Silver Deduplication & Delta MERGE
02_silver_merge.py_commit_timestamp DESC.DELETEoperations and merged into Silver:whenMatchedDelete(condition="updates._change_type = 'delete'")3. Data Quality & Validation Parity
04_data_quality.pyshipped_at >= created_at) and aggregates order item subtotals to verify they match the order headertotal_amount.SHIPPEDorCANCELLEDback toPENDING).4. Time Travel & Recovery Demo
02_silver_merge.py.option("versionAsOf", 0)and executes a metadata rollback usingdeltaTable.restoreToVersion(0).Architecture Tradeoffs
Let me know if you have any questions during the review!