Finance says yesterday's revenue is wrong again. The nightly incremental load duplicates orders on re-runs, drops late updates, shifts orders to the wrong day and loses cents. Make the load idempotent and the revenue report trustworthy.
This is the practice version. Assessments always use a variant you have never seen.
Finance closed the books and found yesterday's revenue 6% higher than the payment processor's. The nightly job in etl/load.py copies changed orders from the shop's export into the
warehouse table fact_orders, and etl/report.py turns that table into daily revenue.
What the export guarantees:
updated_at is at or after the watermark minus 15 minutes. Rows can arrive
up to 15 minutes late, so an export may include rows older than the last watermark.paid → refunded).run_incremental safe to re-run: one row per order, always the newest version.updated_at in UTC, put each order on its UTC order_date, and parse money exactly.daily_revenue must count paid orders only, as amount − discount (a missing discount is 0).Run python3 -m unittest discover -s tests. A hidden suite replays late, duplicated and corrected exports.