Q&A-1Design orchestration for a daily source-to-warehouse data product.
Answer
The 90-second answer
Before drawing a DAG I pin three things: what the consumer does with the data and by when, which logical interval a run represents, and where the source's authoritative cut sits for that interval. Everything else follows.
Assume a daily product. Source is an OLTP Postgres plus an events table. Airflow 2.9 orchestrates, dbt transforms, Snowflake stores. Two consumers: a finance mart that must be correct by 09:00 UTC, and a feature job that must have the table by 07:00 UTC. Missing the feature deadline yields a stale model; missing finance yields a wrong number. That asymmetry sets the design: publish a version early, gate correctness on its own, never let DAG success stand in for data correctness.
The graph is one chain per source (readiness sensor, extract to immutable landing, validate, transform, reconcile) meeting at a publish task that also notifies consumers. Independent sources fan out in parallel and converge only at publish.
Why landing is immutable
Write raw bytes to object storage under a stable key, e.g. landing/orders/ingest_date=2024-03-10/extract_ts=20240310T0512Z/part-000.parquet. A transform is now a pure function of (raw partition, code version, data_interval). Re-running it after a bug fix reproduces the same output, so you can diff the new result against the old one. If the extract instead overwrites a landing table or re-queries the source, replay is gone: the source has moved on and last Tuesday's wrong number can never be reconstructed. Replay then costs a warehouse scan: an X-Small Snowflake warehouse bills 1 credit per hour, 60-second minimum per resume: instead of a re-extraction against production, which is the expensive and sometimes impossible half.
Choices, and what decides them
| Decision | Use this | Instead of | Deciding criterion |
|---|---|---|---|
| Source arrival | Airflow sensor, poke_interval=60, mode="reschedule", timeout=3h | Airflow 2.4+ datasets (assets in 3.0), Dagster asset sensors | Arrival predictable within a window: sensor, keep it simple. Unpredictable: event-driven, because a polling sensor holds a worker slot |
| Incremental strategy | MERGE on (partition, natural_key) | INSERT OVERWRITE on the partition | Overwrite is cheaper and atomic when the model is a full rebuild of one day; merge when you receive deltas only or must keep history |
| Publication | Stage, then ALTER TABLE staging SWAP WITH live (Snowflake, metadata-only) | DELETE + INSERT into the live table | Consumers must never read a half-published day |
Failure modes and what you alert on
| Failure | Signal | Response |
|---|---|---|
| Late source | Sensor times out at 06:00 UTC | Fail that interval, do not publish, auto-trigger on arrival |
| Partial input | Extracted max(event_time) < data_interval_end | Mark partition incomplete and refuse publish; row count alone misses truncation at a page boundary |
| Duplicate trigger | Two runs for the same interval | Idempotent key means the second merge is a no-op; alert on attempt count, not on rows |
| Worker lost after commit, before ack | Task retries | Safe only because the write is keyed; a non-idempotent publish here is a real corruption path, so set retries=0 on publish |
| DST boundary | 23-hour or 25-hour logical day | Store UTC, compute the interval in the source's business timezone. 2024-03-10 US/Eastern is [05:00Z, 2024-03-11T04:00Z), 23 hours; 2024-11-03 is 25 |
| Schema change | Validation compares against the previous landing schema | Quarantine that partition, page the owner, keep the prior version live |
Numbers to bake in
Airflow defaults are retries=0 and no execution_timeout, so set them: extract and transform retries=3, retry_delay=5min, retry_exponential_backoff=True, max_retry_delay=20min. Bound concurrency rather than hoping: a source_api pool of 4 slots holds you under a 10 rps vendor limit, and a snowflake_load pool of 8 matches dbt threads: 8 (default is 1) plus the warehouse's active statements. Set max_active_runs=1 on the daily DAG (default is 16) so a slow run cannot overlap the next interval. Backfills run as a bounded date range into a dedicated pool, on separate capacity, so a 30-day replay cannot starve the 06:00 job.
Monitor scheduler and queue delay, event-time freshness (max(event_time) versus now, not task status), retry counts, pool saturation, and consumer delivery. Test source outage, sink outage, partial publish, duplicate trigger and the DST day; a green leaf task is not acceptance evidence.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.