Submit assignment for ticket reservation system#10
Open
Poorva28 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
This PR adds a small CDC lakehouse solution for a ticketing reservations system. The goal is to build a simple, reliable CDC pipeline that supports replay safety, schema evolution, historical tracking, current-state reporting and data validation.
What’s Included
sql/source/postgres_schema.sqlandsource/models.pypipeline/cdc.pysql/spark/raw_s3_event_contract.sqlsql/spark/structured_streaming_pseudocode.pysql/spark/iceberg_tables.sqlpipeline/lake.pypipeline/warehouse.pysql/snowflake/pipeline/schema_contracts.pycatalog/catalog.jsonLOCAL_VALIDATION.mdSOLUTION.mdSource Schema Design
The source schema models a ticketing and reservations workflow.
Tables:
venueseventscustomersseatsreservationsreservation_itemspaymentsticketsStrong entities:
venues: independent place where events occurevents: independently scheduled inventory containercustomers: independent buyer identityreservations: main transaction root connecting customer, event, status, timing and moneyWeak entities:
seats: dependent on a venue for real-world identityreservation_items: dependent on a reservation and seatpayments: dependent on a reservation lifecycletickets: fulfillment records tied to reservation itemsKeys and relationships:
venues.venue_idis the parent key foreventsandseatsevents.event_idis referenced byreservationsandticketscustomers.customer_idis referenced byreservationsandticketsreservations.reservation_idis referenced byreservation_itemsandpaymentsreservation_items.reservation_item_idis referenced byticketsreservation_itemsenforces uniqueness on(reservation_id, seat_id)ticketsenforces one ticket per reservation itempaymentsenforces unique provider referencesIndexes:
Validation rules:
hold_expires_atArchitecture
The design follows this flow:
CDC Strategy
Changes are captured as Debezium-style CDC events with:
Replay/restart behavior:
Duplicate handling:
event_idevent_idevent_idvaluesDelete handling:
is_deleted = trueLake and Warehouse Modeling
Lake modeling:
Warehouse modeling:
source_lsnvaluesTime travel / restore:
valid_from,valid_to,is_currentandis_deletedSchema Change Safety
Incompatible changes are detected by comparing incoming/event schemas against the registered source contract.
Detected incompatible changes include:
Ingestion stop behavior:
IncompatibleSchemaChangeops.schema_failuresFailure surfacing:
Validation Parity
Failure checking:
tests/test_data_quality.pyverifies reservation total mismatches are detectedscripts/run_data_quality_checks.pyprovides a local validation scriptCatalog Exposure
Dataset metadata is published in
catalog/catalog.json.The catalog includes:
Each catalog entry includes metadata such as:
Local Setup
cd submission/ticket-reservations python -m pip install -r requirements.txtRun Validations
The local test harness uses DuckDB to simulate the critical behavior without requiring live AWS, Spark, Iceberg, Kafka or Snowflake infrastructure.
Assumptions
source_lsnis the primary ordering signal for warehouse current-state mergesevent_idTradeoffs and Limitations
Responsible AI Usage
AI helped draft the first version and organize the structure. The final design, naming and failure behavior were reviewed and simplified to match the requested pipeline shape.