Repository navigation
Java SDK: Trigger another Dag's run from a native Java Dag - #74440
Merged
jason810496 merged 12 commits intoOct 9, 2026
Merged
jason810496 merged 12 commits into
jason810496 merged 12 commits into
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-trigger-dag-run
branch
from
October 8, 2026 05:33
3fe0637 to
af569b2
Compare
kaxil
reviewed
Oct 8, 2026
A native Java Dag could not start another Dag's run. Airflow's
TriggerDagRunOperator is Python, and a Java bundle has no Python Dag file to
declare one in, so a Java Dag that fans out to another Dag needed a Python
counterpart for that one task.
A `TriggerDagRun` passed to `dag.task` declares a task that has no Java body
to run; the Java runtime runs it as `TriggerDagRunOperator` does. Its
settings are named as Python names the operator's parameters:
```java
dag.task("trigger_downstream",
new TriggerDagRun("downstream_etl")
.config("wait_for_completion", true)
.config("conf", Map.of("rows", 2)));
```
An annotated Dag declares one from an ordinary `@Builder.Task` method that
returns a `TriggerDagRun`. The serialized Dag has to carry what is
triggered, so that method runs when the Dag is built rather than when the
task runs, and therefore takes no parameters.
The task serializes as Python's own `TriggerDagRunOperator`: its template
fields, its UI colour and extra link, and a `dag_dependencies` entry, so the
Airflow UI draws the dependency between the two Dags. Python writes only an
operator's template fields and keeps the rest in the Dag file; a Java Dag
has no such file, so every setting the author made is written too.
The runtime records the triggered run's link and ID as XComs, skips or fails
on a run that already exists, and waits for completion either by polling or,
with `deferrable`, by deferring to the Python triggerer's DagStateTrigger and
resuming from the event it fires. That makes this the first Java runtime to
emit DeferTask and a skipped TaskState.
`scripts/ci/lang_sdk_serialization/test_dags.yaml` now gives the shared
trigger Dag a real logical date instead of a Jinja template, because the SDK
takes one as a date-time. The Go SDK is making the same change in #74417;
whichever lands second drops that one line, and until then the Go
serialization conformance check reports that single difference.
jason810496
force-pushed
the
jason/java-sdk/native-dag-trigger-dag-run
branch
from
October 8, 2026 11:46
af569b2 to
93f3da6
Compare
jason810496
force-pushed
the
jason/java-sdk/native-dag-trigger-dag-run
branch
from
October 8, 2026 14:46
93f3da6 to
c4a82f6
Compare
jason810496
commented
Oct 9, 2026
jason810496
left a comment
Member
Author
There was a problem hiding this comment.
Thanks for the review.
jason810496
marked this pull request as ready for review
October 9, 2026 06:30
jason810496
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jscheffl,
potiuk and
uranusjr
as code owners
October 9, 2026 06:30
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 not start another Dag's run.
TriggerDagRunOperatoris Python, and a Java bundle has no Python Dag file to declare one in, so a Java Dag that fans out to another Dag needed a Python counterpart for that one task.What changes
A
TriggerDagRunpassed todag.taskdeclares a task with no Java body; the Java runtime runs it asTriggerDagRunOperatordoes. Its settings are named as Python names the operator's parameters.TriggerDagRunOperator— its template fields, UI colour and extra link — plus adag_dependenciesentry, so the UI draws the dependency between the two Dags. Python writes only an operator's template fields and leaves the rest to the Dag file; a Java Dag has no such file, so every setting the author made is written too.deferrable, by deferring to the Python triggerer'sDagStateTriggerand resuming from the event it fires. This is the first Java runtime to emitDeferTaskand a skippedTaskState.One shared fixture line
scripts/ci/lang_sdk_serialization/test_dags.yamlnow gives the shared trigger Dag a real logical date instead of a Jinja template, because the SDK takes one as a date-time. #74417 makes the same change for the Go SDK; whichever lands second drops that line, and until then the Go serialization conformance check reports that single difference.Was generative AI tooling used to co-author this PR?