Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Databases, SQL & BIData / ETL / BISeniorCommonScenario

How would you test batch and streaming pipelines with late, duplicate and out-of-order events?

Answer

Define the product's event-time, processing-time, deduplication, watermark and replay rules before choosing expected results. Inject late, repeated, reordered and missing events around window boundaries, then verify both intermediate state and final aggregates after the allowed lateness expires. Replaying the same input should produce the documented idempotent result, and operational metrics should expose dropped, delayed or quarantined records.

Strong answer includes

  • distinguishes event time from processing time
  • tests watermarks, replay and idempotency at boundaries
  • verifies data results and operational evidence

Practical example

Detect duplicate event IDs before validating aggregates
Dialect · Portable SQLRuntime · static example

Requires the raw_events ingestion table and controlled late/duplicate/reordered events.

WITH ranked AS (
  SELECT
    event_id,
    event_time,
    ingested_at,
    ROW_NUMBER() OVER (
      PARTITION BY event_id
      ORDER BY ingested_at, event_id
    ) AS copy_no
  FROM raw_events
)
SELECT event_id, event_time, ingested_at
FROM ranked
WHERE copy_no > 1
ORDER BY event_id, ingested_at;

Streaming tests need controlled late, duplicate and reordered inputs. This SQL check verifies whether the raw input contains repeated event IDs; the pipeline assertion then proves the documented deduplication, watermark and replay rules prevent those copies from double-counting the final aggregate.

Expected result: Known injected duplicates are visible in raw data but contribute only according to the documented deduplication rule downstream.

#data#streaming#batch#events

Sources

Develop and test Dataflow pipelinesGoogle Cloud · Unit, integration and end-to-end testing for batch and streaming pipelinesAdd data tests to your DAGdbt Labs · Reusable assertions for analytics transformations and data contractsGreat Expectations CoreGreat Expectations · Data-quality expectations, validation definitions and evidence