Submit CDC lakehouse reliability assignment - #7
Open
singhsimer09-max wants to merge 1 commit into
Open
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.
PR: CDC Lakehouse Reliability Assignment
Summary
This PR implements a CDC lakehouse reliability pipeline using Databricks, PySpark, and Delta Lake. It simulates a wallet/payments source system, writes CDC events to a Databricks Volume, ingests them into an append-only Bronze Delta table, applies schema-safe Delta merges into Silver current-state tables, runs validation checks, documents catalog metadata, and demonstrates Delta time travel restore.
Source Schema Design
The source model has five tables:
customerswallet_accountsmerchantspayment_transactionspayment_attemptscustomers,wallet_accounts,merchants, andpayment_transactionsare strong entities.payment_attemptsis a weak entity because each attempt depends on a parent payment transaction.The source design includes primary keys, foreign keys, indexes, timestamps, nullable optional fields, currency fields, status domains, non-negative wallet balance checks, and positive payment amount checks.
CDC Strategy
CDC is simulated as JSON files in a Databricks Volume. Each event includes
source_table,cdc_operation,cdc_sequence,source_commit_ts,schema_version, andpayload_json.The sample stream contains inserts, an update, and a delete. In production, this simulated stream would be replaced by database logs, Debezium, Kafka, Fivetran, or another CDC connector.
Lake And Warehouse Modeling
The lake layer is
robustrade_dev.bronze.cdc_events. It is append-only and retains full CDC history.The warehouse layer contains Silver current-state tables. These tables are built with Delta
MERGE, ordered bysource_commit_tsandcdc_sequence, and retain only the latest non-deleted row per key.Schema Change Safety
Before writing to Silver, each CDC payload is parsed using an explicit schema and checked against a contract. Missing required fields, data type changes, or required fields becoming nullable stop the pipeline before downstream mutation.
Validation Parity
Warehouse checks mirror source business rules:
Catalog Exposure
Catalog metadata is provided in
catalog.ymland the08_catalog_metadatanotebook. It documents dataset name, layer, platform, owner, description, consumers, primary key, and update cadence.Historical Recovery
Silver tables can be rebuilt from Bronze. The restore notebook also demonstrates Delta Lake time travel with
DESCRIBE HISTORYandRESTORE TABLE.Responsible AI Usage
AI assistance was used to help structure the notebooks, debug Databricks errors, and refine explanations. I personally ran the notebooks in Databricks, reviewed the outputs, corrected errors, and validated the final pipeline behavior.
Testing And Validation
Completed validations:
payment_transactions_currentshowed transactiont_001asSETTLED.SETTLED.