Skip to main content
Sign in with Google (Free) to save your verified DynaDatumKart checkpoints & earn your 500-point capstone badge.
Sign In with Google
SQL Detective Capstone • $800K Double-Billing Incident

DynaDatumKart $800K Streaming Idempotency Investigation

Solve all 4 interactive SQL checkpoints below to isolate the duplicate Kafka payloads, deduplicate Silver orders, reconcile dropped payment webhooks, and compute the automated refund queue.

Practice Silver Deduplication Lab
Active Double-Billing Discrepancy
$800,000.00
Verified: $0 (0/4 SQL checkpoints passed)
$800,000 Discrepancy$0.00 Target

Interactive SQL Forensic Checkpoints (0/4 Verified)

CHECKPOINT 1 • STREAM DEDUPLICATION$280K

Find Duplicate Kafka Order Events

Kafka producer timeouts retried payment events without deduplication, creating duplicate rows with the same (order_id, idempotency_key).

Your Detective Mission: Query bronze.kafka_orders_raw to find duplicate (order_id, idempotency_key) pairs where COUNT(*) > 1. Return order_id, idempotency_key, and COUNT(*) AS event_count ordered by order_id.
bronze.kafka_orders_raw (order_id, idempotency_key, amount)
checkpoint_1.sql
CHECKPOINT 2 • IDEMPOTENT UPSERT$240K

Deduplicate Silver Orders with ROW_NUMBER()

Worker restarts re-ran append writes into silver.dynadatumkart_orders, leaving multiple versions per order_id.

Your Detective Mission: Use ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY updated_at DESC) AS rn on silver.dynadatumkart_orders to return only the newest row (rn = 1) with order_id, payment_id, captured_amount ordered by order_id.
silver.dynadatumkart_orders (order_id, payment_id, captured_amount, updated_at)
checkpoint_2.sql
CHECKPOINT 3 • FINANCIAL RECONCILIATION$160K

Payment Gateway Webhook Drift Reconciliation

Dropped payment webhooks left charged gateway payments stuck in PENDING or missing in silver.dynadatumkart_orders.

Your Detective Mission: Left join bronze.payment_gateway_audit g to silver.dynadatumkart_orders o on g.order_id = o.order_id. Find rows where g.gateway_status = 'CHARGED' AND (o.order_status IS NULL OR o.order_status != 'COMPLETED'). Return g.order_id and g.charge_amount ordered by g.order_id.
bronze.payment_gateway_audit (gateway_txn_id, order_id, charge_amount, gateway_status)silver.dynadatumkart_orders (order_id, order_status)
checkpoint_3.sql
CHECKPOINT 4 • AUDIT & REMEDIATION$120K

Calculate Automated Customer Refund Queue

Customers billed more than once for the same payment_id need an automated refund amount calculated.

Your Detective Mission: Query silver.charges_log grouped by customer_id and order_id where COUNT(*) > 1. Return customer_id, order_id, and ROUND(SUM(charged_amount) - MAX(charged_amount), 2) AS refund_due ordered by customer_id.
silver.charges_log (charge_id, customer_id, order_id, charged_amount)
checkpoint_4.sql