Chapters & contents Lesson 1 of 12
3 min read
Data engineeringExpanded reading

Build a pipeline that can run twice safely

Define the grain of a dataset and make retries an explicit part of the design.

What you’ll learn

  • Specify a dataset row’s meaning and key
  • Trace deduplication and aggregation on a small input
  • Distinguish event time from processing time

Define the row before choosing a tool

Suppose a platform exports lesson-completion events. Each event carries an event identifier, learner identifier, lesson identifier, occurrence time, and schema version. Define the grain: one row represents one emitted completion event, rather than one learner or one lesson. Two completions for different lessons must remain separate even if the same person generated them. This simple sentence shapes keys, deduplication, validation, and later aggregates. A powerful distributed processing engine cannot infer a missing business definition for you.

Trace a duplicated input

Take three arriving records: event A for lesson one, event B for lesson two, and a repeated copy of A. A raw ingestion table may retain all three for audit, while a curated event table keyed by event identifier should contain two unique events. Aggregating the raw table would incorrectly report three completions. Aggregating the curated table produces two. Decide how to handle a repeated identifier with different content: silently keeping an arbitrary copy can conceal upstream corruption, so quarantine or explicitly resolve that conflict.

Make reruns produce the intended result

An idempotent pipeline step reaches the same intended state when the same logical input is applied again. For a daily completion summary, one approach is to recompute a known partition and replace that partition through an appropriate atomic publication mechanism. Another is a carefully keyed upsert with consistent transformation rules. Simply adding today’s count to an existing total on every retry is not idempotent. Write a recovery story before scheduling the job, including what happens if it fails during output publication.

Separate when something happened from when it arrived

A learner can finish a lesson offline at 23:58 and synchronize at 00:10 the following day. Event time describes the completion; processing time describes when the pipeline handles it. If the product reports learning by the learner’s event date, late arrivals may require revising an earlier aggregate. Streaming windows, watermarks, and triggers express policies around such data, but no setting makes all future lateness impossible. Document the accepted lateness and correction policy so reports have a shared meaning.

Validate meaning as well as shape

Rejecting a malformed timestamp is a schema check. Checking that a completion references a known lesson is a semantic check. Checking that a partition unexpectedly lost nearly all events is an operational quality check. Keep rejected records in a controlled location with a reason and limited retention, then make the rejection count visible. For a first project, use a tiny local dataset, run the transformation twice, introduce a duplicate and a late event, and compare the final published rows after each run.

Try it yourself

A daily summary is made from events A, B, B, and C. C occurred yesterday but arrived today. Specify the unique-event count and the two policies needed before assigning daily totals.

Show a possible solution

There are three unique event IDs if the two B records match. Define whether reporting uses event time or processing time and define how late arrivals revise already published days. Also define a conflict policy if repeated IDs contain different payloads.

Check your understanding

Try 11 questions across data engineering. Read each explanation and revisit anything that needs another pass.

Practise this subject

Go to the source

Use these primary references to check details and explore the topic further.

Saved in this browser. Signed-in progress syncs to your account.