Skip to content

ADR-0072: Airflow partitions and watcher settling

Architecture: Section 13, The Airflow plugin

Builds on ADR-0037 to ADR-0039 (the plugin), ADR-0048 (WATCHER), ADR-0049 (orchestrator protocol), ADR-0055 (asset URIs) and ADR-0071 (partition keys). It is the Airflow item of the 1.5 milestone.

Context

ADR-0071 gave every interval window a key and put it in the artifacts. Airflow 3.2 to 3.4 can drive a DAG from asset events that carry a partition key (PartitionedAssetTimetable), so one run of a DAG can mean one window. Three things are missing for that: the orchestrator protocol cannot say "run this window", the plugin does not tell Airflow which partitions a task produced, and a few WATCHER and rendering rules still depend on the shape of the whole run instead of on the unit.

What the three Airflow lines support, checked in the installed packages:

Airflow PartitionedAssetTimetable Partition key on the DAG run outlet_events[asset].add_partitions
3.2.2 yes yes (dag_run.partition_key) no
3.3.x yes yes, and context["partition_key"] yes
3.4.0 yes yes, and context["partition_key"] yes

Options

  • A new pipeloom run flag for a window, or reuse backfill. A range does not fit: Airflow gives one key, and each model has its own grain and key format. A flag that takes the key and lets each model read it under its own spec keeps the key the only thing the orchestrator needs. Chosen: --partition-key KEY, which the core turns into a backfill-style run (same ledger, no lookback, up-to-date windows are not run again).
  • Partitions on Airflow 3.2. The consuming side works on 3.2 (the key is on the DAG run), but a task cannot add partitions to an asset event there, so a produced partition would never reach a downstream DAG. Rejected as half a feature: the option needs 3.3, and 3.2 gets a diagnostic (PLA010).
  • Partitioned assets on by default. The feature is new on Airflow's side and its API may still move. Chosen: opt-in, documented as experimental.
  • All modes. KUBERNETES and DATABRICKS never see the unit's result in the task, so they cannot say which partitions ran. Rejected for now (PLA002).
  • Task ids that depend on the selection. The id of a unit used to get a hash only when it collided with another selected id, so adding a unit to select could rename another and orphan its history. A new id rule would rename every unsafe id in a minor. Chosen: keep the 1.4 rule and judge collisions over the whole plan.

Decision

pipeloom run --partition-key KEY (orchestrator protocol, optional). Each selected interval model runs the one window the key names under its own partition spec (ADR-0071), through the path of pipeloom backfill: the ledger records the window, windows it already holds are not run again, and the unit that finds nothing missing settles as succeeded with outcome: up_to_date. Models without incremental.interval run as in a normal run. A key that names no window of a selected interval model (wrong shape, impossible date, a week key that is not a Monday) is PLX133, exit 2, nothing runs; in unit mode the unit fails with PLM209 instead. A selection with no interval model is not PLX132 here: its models run as in a normal run. A key whose window starts before the model's begin (by grain) or after the run's start fails the unit with PLM209 and is never reported as up to date, so no orchestrator emits an event for it. The flag is not valid with --full-refresh or --backfill, and build does not take it. Backfill gains the optional partition_key; its start and end are placeholders then.

Opt-in partitioned assets (RenderConfig.partitioned_assets, default false, experimental). It needs emit_assets, the LOCAL, VIRTUALENV or WATCHER mode, and Airflow 3.3 or later (PLA010 otherwise; PLA002 for the other two). Using it prints the warning PLW001, the first code of the experimental layer of stability; it is promoted or removed within two minor releases. The DAG's schedule stays the user's: a PartitionedAssetTimetable over the upstream assets. With the option on:

  • A DAG run that carries a partition key passes it to the unit command (LOCAL, VIRTUALENV, and the WATCHER producer) as --partition-key. A run without a key runs as before.
  • After a successful unit that is an interval model (its unit.succeeded event or attempt row has partition_keys, possibly empty), each of its asset outlets gets add_partitions: the DAG run's key when it has one and the unit ran that window or reports outcome: up_to_date (the signal ADR-0071 promised, so a downstream partition is not stuck; a unit that held the window back emits nothing), otherwise the keys the unit ran. Units that are not interval models emit no partition.
  • In WATCHER mode the watcher emits, from the attempt row, because the producer's task knows no unit.

The key is read from dag_run.partition_key, or from the context where Airflow 3.3 puts it.

Templated emit_assets: deferred. The URI is already a template (asset_uri, ADR-0055); nothing in the milestone needs a second template.

WATCHER settling. decide() no longer maps a results row of status skipped to "run the unit here". A row skipped by the scheduler (upstream_failed, upstream_incomplete, fail_fast) means the unit never ran, so the decision is the new kind skipped (the trigger event is skipped, replacing run) and the watcher raises AirflowSkipException on its first try: no retry, no deferral, no run in the sensor. Rerunning a unit is only a clear of the watcher (try 2 or later, ADR-0048 rule 6), as before. The Airflow task is skipped whatever the reason, and finalize still fails the DAG run for a failing reason through the core's results.

Bounded XCom. The producer and the watchers return nothing and push nothing, and a deferred watcher carries only its trigger state (paths and numbers). A test runs 200 watchers, one of them failing, and bounds what the run leaves in XCom; the failure text goes to the log and the exception, never to XCom.

Select and exclude on the full graph. The selection is evaluated on the whole plan (it already was). The rendered edges now follow it: a rendered unit depends on its nearest rendered ancestors, through units the selection left out, so ordering the selection kept in the plan is kept in the DAG. A direct edge is unchanged.

Task ids stay those of 1.4. The rule of ADR-0037 is unchanged: unsafe characters become _, and an id that collides, is longer than 200 characters or is reserved gets a hash. What changes is where collisions are looked for: over every unit of the plan, not over the selection. A plan without collisions renders the ids of 1.4.1 (sales/orders is sales_orders), and select never renames a task. A plan with a colliding pair now hashes both units even when the selection holds only one of them, which can rename that task once. In DATABRICKS mode the keys are Databricks task keys and the universe is the rendered keys.

Parse-time budget tests. The wall-clock budgets stay, and a parse that is over budget is timed again up to three times; the best time counts. One slow import on a busy runner no longer fails a run, a regression still does, since it is slow every time.

CI. The Airflow job already covers 3.2.2 (floor), the 3.3 line (af33) and 3.4.0 (latest, the lock). The leg names do not change, so no branch protection update is needed. The partition tests patch the version check and run on all three; a test with the real check expects PLA010 below 3.3.

Consequences

  • One DAG run can mean one window, from the asset event to the ledger, and the same key shows up in the artifacts, the OpenLineage facet and Airflow.
  • The Astro example needs a runtime on Airflow 3.3 or later to try it; this was not run (it needs Docker). The behavior is covered by DAG-level tests with a fake context.
  • Windows of different grains in one selection share one key; a model whose format does not read it fails the run with PLX133 up front. Use one grain per partitioned DAG.
  • A watcher no longer runs a scheduler-skipped unit. A user who relied on that clears the watcher instead.

Provenance: designed from this project's windows and ledger and the public Airflow 3.x documentation on partitioned assets; no code was copied.

Status

Accepted

Date

2026-12-05