Repository navigation
Java SDK: Pick one of two tasks with a condition - #74438
Merged
jason810496 merged 6 commits intoOct 9, 2026
Merged
Conversation
jason810496
added this pull request to stack #74441
October 8, 2026 05:01
This was referenced Oct 8, 2026
jason810496
removed this pull request from stack #74441
October 8, 2026 05:06
jason810496
added this pull request to stack #74442
October 8, 2026 05:06
jason810496
force-pushed
the
jason/java-sdk/native-dag-if
branch
from
October 8, 2026 05:33
95369c1 to
30e5218
Compare
kaxil
reviewed
Oct 8, 2026
A native Java Dag could only run every task it declared: it had no way to let a task's result decide what runs next, so a Dag that loads only when there are rows had to be split in two or fall back to a Python stub. `DagDef.If` and `@Builder.If` declare a task whose boolean names the side that runs; the other is skipped. The deciding task carries `_can_skip_downstream`, so Airflow skips a cleared side again rather than running it, and the SDK writes the `skipmixin_key` XCom before the skip, as Python's SkipMixin does. It skips only the side not taken, so a task after both sides needs a trigger rule such as `none_failed_min_one_success`. `If` is capitalized because `if` is a Java keyword and `@Builder.If` reads the same way. With no task id given, one is derived from the condition class's simple name, so `HasRows.class` becomes `hasRows`. The runtime reaches `SkipDownstreamTasks` through the transport client only, never through the task-facing `Client`, so a task body cannot skip tasks the Dag did not declare it may.
jason810496
force-pushed
the
jason/java-sdk/native-dag-if
branch
from
October 8, 2026 11:46
30e5218 to
dbe29e4
Compare
jason810496
marked this pull request as ready for review
October 8, 2026 12:56
jason810496
commented
Oct 8, 2026
jason810496
left a comment
Member
Author
There was a problem hiding this comment.
Thanks for the review.
guan404ming
approved these changes
Oct 9, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A native Java Dag could only run every task it declared. Nothing let a task's result decide what runs next, so a Dag that loads only when there are rows had to be split in two or fall back to a Python stub.
What changes
DagDef.Ifand@Builder.Ifdeclare a task whose boolean names the side that runs; the other is skipped.Ifis capitalized becauseifis a Java keyword, and@Builder.Ifreads the same way._can_skip_downstream, and the SDK writes theskipmixin_keyXCom before the skip, so Airflow skips a cleared side again rather than running it, as Python'sSkipMixindoes.none_failed_min_one_success.SkipDownstreamTasksis reachable through the transport client only, never through the task-facingClient, so a task body cannot skip tasks the Dag did not declare it may.branchDags, andbranchingis marked supported.Was generative AI tooling used to co-author this PR?