CDC Pipeline for Global commodity trade and logistics#11
Open
Harshal1309 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.
Summary
I have designed and implemented a Change Data Capture (CDC) Lakehouse synchronization pipeline under
submission/harshal-logisticstailored for ROBUSTRADE's core business of international commodity trade, logistics, and border customs clearances.The pipeline ingests data from a transactional source system, writes it to a raw append-only Lake, processes it under safety constraints, and updates a near real-time analytical Warehouse. The implementation features comprehensive Point-in-Time recovery (Time-Travel) and strict business rule data quality validators.
Source Schema Design
trade_partners: Profiles buyers and sellers.trade_contracts: Commodity sales contracts (e.g. Copper, Cocoa) including pricing and tons.trade_contracts):shipment_cargo: Container freight carrier numbers, load ports, discharge ports, and actual delivery dates.customs_clearances: Border clearances, duty fee pricing, and approval statuses.settlement_transactions: Wire transfer and letter of credit payments.compliance_statusasactive/suspended/under_review), metric tons and monetary values must be non-negative, and shipment delivery dates are checked.CDC Strategy
CDCRecordcarrying a monotonic sequence number (our Log Sequence Number/LSN)._deleted = true) to preserve audit capabilities.records_since(offset)to resume ingestion after a restart.record.sequence > current_warehouse_row._cdc_seq. Duplicate arrivals and older out-of-order LSN messages are safely discarded.Lake and Warehouse Modeling
lake_cdc_eventstable, serializing row changes as raw JSON events alongside captured timestamps.wh_) keep the consolidated latest status state and track CDC metadata.reconstruct_warehouse_at(conn, lsn)truncates warehouse tables and replays lake records sequentially up tolsnto restore the exact historical database snapshot at that point in time.Schema Change Safety
1, halting the CI/CD build.Validation Parity
total_value_usd == weight_metric_tons * price_per_ton_usd.<= total_value_usd.actual_deliveryis set) if customs clearance status isrejectedorheld_in_customs.run_data_quality_checks.py. Mismatches list violations and return exit code1.Catalog Exposure
Lake and warehouse datasets are published in
catalog/catalog.jsonwith dataset descriptions, data layer tags (lake vs warehouse), schemas, update cadences, owners, and downstream consumers.Validation
All checks and pipeline validations were executed and verified locally:
pytest -v submission/harshal-logistics/tests # Result: 29 passed in 3.26spython submission/harshal-logistics/scripts/check_schema_contracts.py # Result: All schema contracts passed (5 tables checked).python submission/harshal-logistics/scripts/run_data_quality_checks.py # Result: All data quality checks passed (system validations and business rules verified).python submission/harshal-logistics/scripts/validate_catalog.py # Result: Catalog validation passed (6 datasets verified).Known Limitations / Next Steps