The problem
Analytical questions kept requiring fresh ad-hoc queries against raw, inconsistent extracts — slow to produce, impossible to reproduce. The fix wasn't a better query; it was a warehouse.
The build
Raw data lands untouched, loads into typed staging via COPY INTO, transforms once inside Snowflake — window-function dedupe, conformed types, MERGE-based incremental upserts — and publishes a documented star schema (1 fact + dimensions) as the single interface for analytics.
WITH ranked AS ( SELECT s.*, ROW_NUMBER() OVER ( PARTITION BY order_id ORDER BY updated_at DESC) rn FROM stg_orders s) SELECT * FROM ranked WHERE rn = 1;