Files
airflow/java-sdk/sdk/module.md
T
Jason(Zhe-You) Liu c3043c266c Java SDK: Choose one of several tasks with a branch (#74439)
* Java SDK: Choose one of several tasks with a branch

A condition picks between two tasks, but a Dag that routes work by size or
by region needs more than two, and splitting that into nested conditions
makes the graph unreadable.

`DagDef.Branch` and `@Builder.Branch` declare a task that chooses one of
the tasks listed with `option(...)`; every other one is skipped. The chosen
task's ID becomes the branch's return value, as it does for Python's branch
operators. A branch chooses exactly one case, so a task that runs after
several of them needs a trigger rule such as
`none_failed_min_one_success`.

Each authoring style names the case in the way that style can type-check. A
`BranchTask` returns the case's own class, so javac checks it; two cases
that share a class are rejected where the second is named, since the branch
could not tell them apart. A `@Builder.Branch` method has no such class to
name -- a task method's implementation is generated -- so it returns a
`TaskId` from the generated `<Dag>Builder.TaskIds`, which holds one
constant per task of the Dag. Either way nothing hard-codes a task id
string, and the generated holder is emitted only for a Dag that declares a
branch.

* Java SDK: Name the multi-way branch Switch, as the other SDKs do

* Java SDK: Name a switch case by its task class in both styles

* Java SDK: Say when a switch rejects a choice and when it fails

* Java SDK: Cover a generated switch that names a task it cannot choose

* Java SDK: Check a switch carries the chosen task's id

* Java SDK: Let a wiring view name a switch's cases in more than one call
2026-10-09 14:30:52 +08:00

3.9 KiB
Raw Blame History

Module sdk

The Apache Airflow Java SDK — author and run Airflow task implementations in JVM languages.

Language SDK compatibility matrix

Which Airflow TaskInstance states and capabilities the Java SDK currently supports. The normative meaning of each dimension is defined in the Language SDK conformance specification.

Min. Airflow version: 3.3 · supervisor schema: 2026-10-30

Dimension Tier Supported Since Notes
TaskInstance states
state: success MUST ✓ 3.3
state: failed MUST ✓ 3.3
state: up_for_retry MUST ✓ 3.3 RetryTask
state: skipped SHOULD ✗ – runtime does not emit TaskState skipped yet
state: deferred MAY ✗ – runtime does not emit DeferTask yet
state: up_for_reschedule MAY ✗ – runtime does not emit RescheduleTask yet
state: awaiting_input MAY ✗ – runtime does not emit AwaitInputTask yet
state: removed MAY ✓ 3.3
Runtime capabilities
capability: mixed-lang-stub-target MUST ✓ 3.3 @task.stub
capability: taskflow-binding MUST ✗ – bind @task.stub literal/XCom args to the native handler
capability: task-logging MUST ✓ 3.3 SLF4J + JPL bridged to the task log
capability: xcom-read-write MUST ✓ 3.3
capability: connection-read MUST ✓ 3.3
capability: variable-read-write MUST ✓ 3.3
capability: self-contained-bundle MUST ✓ 3.3 Airflow metadata embedded in the jar artifact
capability: retry-policy MAY ✗ – no task-facing retry-policy API yet
capability: task-state-store MAY ✓ 3.3 Client.getTaskStateStore() get/set/delete/clear
capability: asset-state-store MAY ✗ – no task-facing state-store API yet
capability: asset-event-emit MAY ✗ – runtime does not emit asset events yet
capability: asset-event-read MAY ✗ – no task-facing asset-event API yet
Native-Dag authoring
capability: native-dag-authoring SHOULD ✓ 3.4
capability: task-args MUST † ✓ 3.4
capability: dag-params MUST † ✗ –
capability: taskflow-dependencies MUST † ✓ 3.4
capability: branching SHOULD † ✓ 3.4 DagDef.If and DagDef.Switch, or @Builder.If and @Builder.Switch
capability: dag-test SHOULD † ✗ –
capability: task-group MAY † ✓ 3.4
capability: dynamic-task-mapping MAY † ✗ –
capability: asset-inlets-outlets MAY † ✗ –
capability: asset-scheduling MAY † ✗ –
capability: object-store MAY † ✗ –

Marks: ✓ supported · ✗ not supported · n/a not applicable. A tier marked † applies only when native-dag-authoring is supported.