From 3c350904024db2d84bcb3f006283b04684b005d7 Mon Sep 17 00:00:00 2001 From: LIU ZHE YOU Date: Sun, 27 Sep 2026 14:39:53 +0000 Subject: [PATCH] Java SDK: Describe native Java Dags without reference to Python A Dag authored entirely in Java has no Python in the picture, so teaching its edge verbs as "Java's spelling of >> and <<" asks the reader to know a language the feature does not involve. The mixed-language surface keeps its Python references, because there the Python Dag file is part of what the reader has to understand. --- .../language-sdks/java.rst | 9 ++++----- .../example/nativedag/InterfaceExample.java | 5 ++--- .../main/kotlin/org/apache/airflow/sdk/Deps.kt | 18 ++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst b/airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst index 1561ecfffcfab..45a88789fe641 100644 --- a/airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst +++ b/airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst @@ -537,16 +537,15 @@ calls with no arguments. Native Java Dags ---------------- -A Dag can also be authored entirely in Java, with no Python stub file: the ``DagDef`` and -``TaskDef`` objects hold the tasks, and Java declares the graph. +A Dag can also be authored entirely in Java: the ``DagDef`` and ``TaskDef`` objects hold the +tasks, and Java declares the graph. Building the Dag in Java ~~~~~~~~~~~~~~~~~~~~~~~~ ``dag.task(...)`` registers a task as it creates it and hands back a handle, so there is no second -``addTask`` call to forget. ``before`` and ``after`` draw every edge on this surface — Python's -``a >> b`` and ``b << a`` — and the task body moves the data itself, by reading the upstream's XCom -through ``Client``: +``addTask`` call to forget. ``before`` and ``after`` draw every edge on this surface, and the +task body moves the data itself, by reading the upstream's XCom through ``Client``: .. code-block:: java diff --git a/java-sdk/example/src/java/org/apache/airflow/example/nativedag/InterfaceExample.java b/java-sdk/example/src/java/org/apache/airflow/example/nativedag/InterfaceExample.java index 58c3321825405..bf95a8c54b9c8 100644 --- a/java-sdk/example/src/java/org/apache/airflow/example/nativedag/InterfaceExample.java +++ b/java-sdk/example/src/java/org/apache/airflow/example/nativedag/InterfaceExample.java @@ -24,9 +24,8 @@ import org.apache.airflow.sdk.*; -// A Dag defined entirely in Java, interface-style: no Python stub file -// describes it. dag.task registers a task as it creates it and hands back the -// handle, and `before`/`after` wire the graph -- Java's spelling of `>>` and `<<`. +// A Dag defined entirely in Java, interface-style. dag.task registers a task as +// it creates it and hands back the handle, and `before`/`after` wire the graph. public class InterfaceExample { private static final System.Logger log = System.getLogger(InterfaceExample.class.getName()); diff --git a/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Deps.kt b/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Deps.kt index 7860a69a0c82b..38a14d0035477 100644 --- a/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Deps.kt +++ b/java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/Deps.kt @@ -24,20 +24,19 @@ interface Deps { /** * A point in the task graph: one task, or a set of them. * - * [Flow] is Java's spelling of Python's `>>` and `<<`, for a dependency - * where nothing flows but the ordering. An edge that carries a value is - * declared by passing the upstream's handle instead. + * [Flow] declares a dependency where nothing flows but the ordering. An + * edge that carries a value is declared by passing the upstream's handle + * instead. */ interface Flow { /** The tasks at this point in the flow. */ fun nodes(): List /** - * Runs the tasks here before each of [next], carrying no value — Java's - * spelling of Python's `>>`. + * Runs the tasks here before each of [next], carrying no value. * * ```java - * loaded.before(cleaned, notified); // load >> [cleanup, notify] + * loaded.before(cleaned, notified); // cleanup and notify both wait for load * ``` * * Variadic, so one call fans out, and it returns its own receiver: a @@ -54,11 +53,10 @@ interface Deps { } /** - * Runs the tasks here after each of [previous], carrying no value — - * Python's `<<`. + * Runs the tasks here after each of [previous], carrying no value. * * ```java - * cleaned.after(loaded, transformed); // [load, transform] >> cleanup + * cleaned.after(loaded, transformed); // cleanup waits for load and transform * ``` * * @param previous Tasks that run before the ones here. @@ -76,7 +74,7 @@ interface Deps { * every edge between two sets: * * ```java - * Flow.of(a, b).before(c, d); // [a, b] >> [c, d] + * Flow.of(a, b).before(c, d); // c and d both wait for a and b * ``` */ @JvmStatic