Commit 491ff46
committed
Fix: Add deduplication to event_details CTE to prevent row fan-out
The event_details CTE was reading from market_details_raw without
deduplication. Since market_details_raw contains temporal snapshots
with multiple rows per event_ticker (indicated by last_updated_ts),
the LEFT JOIN on event_ticker was causing a fan-out, producing
duplicate ticker rows that violated the unique_combination_of_columns
test and cascaded incorrect duplicates into kalshi_market_trades.
Added QUALIFY with ROW_NUMBER() to keep only the latest row per
event_ticker based on last_updated_ts DESC, ensuring 1:1 join
cardinality and preventing duplicate ticker rows.1 parent 4f4ca39 commit 491ff46
1 file changed
Lines changed: 1 addition & 0 deletions
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
0 commit comments