mirror of
https://github.com/apache/airflow.git
synced 2026-11-04 15:53:05 +00:00
* 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