Skip to content
BIASED

Data pipelines and orchestration

Block 1 of 6~3 min

Identify events before scheduling work

An upload arrives after yesterday's preview report was published. Rerunning a script that appends rows adds yesterday's other uploads again, yet ignoring the upload leaves the report incomplete. The problem is the meaning of a result: which events it includes, what it knew at the time, and how a revised result replaces the previous one.

Our running case is a fictional preview service. Five delivered messages below are authored inputs, not production traffic. The complete example uses the Python standard library and a temporary directory; it does not connect to a scheduler, object store or database.

A retry must not create another fact

A scheduled command can run twice because a worker crashes after writing output but before reporting success. The scheduler cannot infer from silence whether the write happened. Appending the same row on the retry duplicates its effect. Refusing to retry instead risks losing work that never finished.

Separate the identity of the event from the identity of its delivery. A card-upload event keeps the same event ID when a broker redelivers it. An attempt has its own operational ID. Deduplicating by attempt would preserve both copies; deduplicating by card alone could incorrectly erase a later edit to the same card. The correct key follows the event contract.

In the fixture, an ID with conflicting content raises an error. Silently choosing whichever delivery arrived last would conceal data corruption or an undefined update rule. A legitimate correction needs an explicit new version or correction event and a defined effect on downstream snapshots.

Batch and streaming describe when work is evaluated

A batch job receives a bounded snapshot and finishes. A streaming computation updates state as events arrive. Either can calculate the number of uploads per event day. They differ in when they expose intermediate answers and how long they retain state for corrections.

A daily batch is convenient when the product can wait and a complete snapshot fits the processing window. A stream is useful when a new upload must affect a queue promptly. Streaming still needs checkpoints, replay and a rule for late events. Batch processing still needs a cutoff and a rule for data discovered after that cutoff. Neither execution mode makes a mutable input reproducible by itself.

The same logical transformation should produce the same answer from the same identified input. If an online path uses a different interpretation of an event, reconciling its output with the nightly job becomes a semantic problem before it becomes a speed problem.

ETL and ELT place the transformation boundary

Extraction reads the source, transformation interprets or reshapes records, and loading writes a destination. ETL transforms before loading into the analytical destination; ELT loads first and transforms there. For previews, a restricted raw-event store can preserve the original event while a separate table exposes only the fields needed for evaluation.

Preserving raw input makes a later correction possible only if retention and access rules permit it. It is not a reason to retain every uploaded document indefinitely. A raw store also does not excuse downstream ambiguity: record the parser version, units, event-ID rule and accepted schema. Otherwise two runs can read the same bytes and disagree about their meaning.

Choose the boundary according to trust, available execution and required reprocessing. A malformed or unauthorized payload can be rejected before the analytical store. A valid record with a later corrected interpretation can produce a new derived version while the permitted original remains identifiable.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Replay events without duplicating their effectoptional

    All events and integer clocks are fictional. The local publication uses a temporary directory only; it does not establish remote exactly-once effects or power-loss durability.

    ~20 min · easier on a computer · The corresponding lesson and basic Python functions.

    Self-check in the notebook — not part of mastery or the certificate.