TECHNOLOGIESTieInn Technologies

Testing incremental loads: windows, watermarks, reruns and idempotency

ETL & Data Warehouse Testing · 7 questions

Short notes

Key idea

Incremental loads load only new data, by date window or watermark. Test that windows are contiguous, every run wrote every source row in its window (both ends), failed runs left nothing, reruns are idempotent (same result twice), late and updated rows arrive, and the target is fresh.

Syntax

-- Expected vs written per successful run
SELECT l.load_id,
  (SELECT COUNT(*) FROM orders o
    WHERE o.order_date BETWEEN l.window_start AND l.window_end) AS expected,
  (SELECT COUNT(*) FROM dw_orders d WHERE d.load_id = l.load_id) AS written
FROM dw_load_log l
WHERE l.table_name = 'dw_orders' AND l.status = 'success';

-- Gaps between windows
... QUALIFY prev_end IS NOT NULL AND window_start <> prev_end + 1;

Example

Shop: runs 5 and 13 dropped the last day of their windows (orders 57, 75); failed run 3 left orders 46 and 47, and the January rerun loaded them again.

Traps

  • Trusting the job's own source count.
  • Testing only mid-window dates.
  • Never rerunning or half-failing a load in test.
  • Watermark loads: updates and late rows get missed.

Want the full lesson with step-by-step examples, a project and a certificate? ETL & Data Warehouse Testing course, ₹120 →

Questions

Open in Code Lab5 free questions
5 questions

    Testing incremental loads: windows, watermarks, reruns and idempotency

  1. Question 1medium

    How many successful orders runs start on the wrong day (a gap or overlap)?

    SELECT COUNT(*) FROM (
      SELECT load_id, window_start,
             LAG(window_end) OVER (ORDER BY window_start) AS previous_end
      FROM dw_load_log
      WHERE table_name = 'dw_orders' AND status = 'success'
      QUALIFY previous_end IS NOT NULL AND window_start <> previous_end + 1
    );
  2. Testing incremental loads: windows, watermarks, reruns and idempotency

  3. Question 2easy

    How many rows in dw_orders were written by failed runs?

    SELECT COUNT(*)
    FROM dw_orders AS d
    JOIN dw_load_log AS l ON l.load_id = d.load_id
    WHERE l.status = 'failed';
  4. Testing incremental loads: windows, watermarks, reruns and idempotency

  5. Question 3medium

    Which load design makes rerunning a month safe (idempotent)?

  6. Testing incremental loads: windows, watermarks, reruns and idempotency

  7. Question 4hard

    A load picks up rows with created_at greater than the last loaded maximum. Which test is most likely to find a bug?

  8. Testing incremental loads: windows, watermarks, reruns and idempotency

  9. Question 5easy

    Which check tells you the warehouse is up to date?

2 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.