4,500 Stores Before Sunrise

A medium Pipeline Design interview practice problem on DataDriven. Design the pipeline on the canvas: sources, transforms, storage and checks, then get feedback on it.

Domain
Pipeline Design
Difficulty
medium
Seniority
L5
Asked in
Walmart

Problem

Every night, 4,500 stores each upload a CSV of current inventory to S3. The replenishment team needs clean, validated data in the warehouse by 7 AM. Some files arrive late, some are malformed, and re-runs have been producing duplicates. Design the pipeline.

The shelves open at 7. The data better be there.

Business requirements

Worked solution and explanation

Why this problem exists in real interviews

Many small files, a hard morning deadline, reruns that have been producing duplicates, and bad files that have been taking the whole load down. Each property has a clean answer; the trap is fitting them together so the orchestrator owns the deadline, the writes are idempotent on a deterministic key, and the bad files quarantine without halting the rest.

The default reach is one job that lists the S3 prefix at midnight, parses every file, and appends to a warehouse table. The first malformed file crashes the parser and the load halts; the on-call engineer reruns and the rows from the first run get appended again, doubling inventory for the stores that succeeded the first time. Late files arriving after midnight miss the load entirely until the next night.


Walk the requirements

Step 1: Land validated inventory by 7am with per-stage alerting

An orchestrator runs the nightly DAG: file-arrival sensors watch the S3 prefix, validation runs as files land, the warehouse load runs once enough files have arrived (with a deadline-driven cutoff for late files), and the publish step runs ahead of 7am. Each stage has its own SLA and its own alert; on-call sees a delayed stage with hours to act, not minutes after replenishment opens an empty dashboard. Without orchestration there's nothing watching the deadline.

Step 2: Reruns don't duplicate, by construction

The warehouse load writes via partition-overwrite keyed on (load_date, store_id). A rerun for the same night replaces those store-rows in the partition rather than appending. Whatever stage failed in the prior run, restarting the DAG produces the same warehouse state. An append-style load is what's been creating the duplicates this month; the partition-overwrite key is the contract that stops it.

Step 3: One bad file doesn't take down the load

Validation runs per file: schema check, size check, parse check. Files that fail route to a quarantine location with the rejection reason; the rest continue to the warehouse load. The orchestrator alerts when quarantine count exceeds an expected baseline so somebody notices a systemic issue (a region of stores all sending malformed files at once) without alerting on the steady drip of one or two bad files. A 'fail the entire load on the first bad file' design is what's been taking the load down; per-file validation with quarantine isolates the failure.


The shape that fits

File-arrival sensors trigger per-file validation; bad files quarantine without blocking the rest; the load writes by (`load_date`, `store_id`) partition-overwrite so reruns are deterministic.
  • store_uploads (source, S3)
  • orchestrator (transform, Airflow); on error: alert; alerting: Stage at risk vs 7am SLA or quarantine count above baseline
  • file_validator (transform, Spark); on error: dlq
  • quarantine_zone (storage, S3); alerting: Quarantine count above expected baseline
  • staged_lake (storage, S3); backfill: partition_overwrite
  • warehouse_loader (transform, Spark); backfill: partition_overwrite; idempotency: staging_table
  • inventory_warehouse (storage, Snowflake); freshness: < 24h; backfill: partition_overwrite
  • replenishment_team (consumer, Tableau); freshness: < 24h
  • store_uploads -> orchestrator
  • orchestrator -> file_validator
  • file_validator -> quarantine_zone
  • file_validator -> staged_lake
  • staged_lake -> warehouse_loader
  • warehouse_loader -> inventory_warehouse
  • inventory_warehouse -> replenishment_team
  • Source + orchestration: store_uploads, orchestrator
  • Validation + stage: file_validator, quarantine_zone, staged_lake
  • Warehouse + consumer: warehouse_loader, inventory_warehouse, replenishment_team

Common follow-up questions