jason810496 opened a new pull request, #73444: URL: https://github.com/apache/airflow/pull/73444
# TS SDK: add multi-way branching with dag.switch - **Depends on the PR for `feature/ts-sdk/conditional-branching` getting merged first** (only the last commit is new here). - **Diff for early review**: https://github.com/jason810496/airflow/compare/feature/ts-sdk/conditional-branching...feature/ts-sdk/multi-way-branching - **next**: `feature/ts-sdk/trigger-dag-run` ## Why The multi-way form of the same construct: TypeScript's `switch`/`case`. ## How - `dag.switch(taskId, decider, cases)` where a case **is** the reference the SDK handed back, following decision 2 of `airflow-core/adr/lang-sdk/0008-control-flow-constructs.md` without divergence. The compiler checks the candidate exists, and renaming a handler cannot silently rewire a Dag. - No default case. A decider returning anything outside its declared cases fails the task, naming what it chose and what it could have chosen, the way `skip_all_except` raises on a task id the Dag does not hold. - Exactly one case is selected. Python's branch callable may return a list of task ids; a single-reference return cannot express that, and no language SDK offers it yet. An earlier draft selected by an author-written label, on the grounds that function names do not survive bundling. That does not apply: a `TaskRef` carries the task's own id, which esbuild never touches. Recorded in `ts-sdk/adr/0002`. ## What - `dag.switch`, rejecting a duplicate case and a branch with no cases. - The decider's chosen task id is returned, which is what a branch puts on the wire. --- ##### Was generative AI tooling used to co-author this PR? - [x] Yes, with help of Claude Code Opus 5 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
