Problems / Apply Daily Upserts / Editorial
UNION ALL
ROW_NUMBER() OVER (PARTITION BY product_id ORDER BY updated_at DESC)
rn = 1
MERGE/upsert logic *feels* like a join problem — match rows, update matches, insert non-matches — but the join formulation multiplies edge cases (multiple updates per key being the one that breaks naive COALESCE(u.col, b.col) merges). Recasting state as "all versions, then keep the latest" turns it into the familiar dedup-by-recency idiom, handles any number of update rounds unchanged, and is exactly how append-only lakehouse tables materialize current state from a change log.
COALESCE(u.col, b.col)
Solve Apply Daily Upserts yourself →