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.
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.
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.
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.