This is an automated email from the ASF dual-hosted git repository.
choo121600 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 1f5b99948a7 Add dynamic task mapping no-op example (#67022)
1f5b99948a7 is described below
commit 1f5b99948a7afe8411bda8f201e725e515543269
Author: 백형준 <[email protected]>
AuthorDate: Thu May 28 09:55:34 2026 +0900
Add dynamic task mapping no-op example (#67022)
---
.../dynamic-task-mapping.rst | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git
a/airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst
b/airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst
index 1a5366cc4c3..d9dfec21fe8 100644
--- a/airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst
+++ b/airflow-core/docs/authoring-and-scheduling/dynamic-task-mapping.rst
@@ -676,3 +676,33 @@ Automatically skipping zero-length maps
=======================================
If the input is empty (zero length), no new tasks will be created and the
mapped task will be marked as ``SKIPPED``.
+
+This can be useful when a Dag discovers work to do at runtime, but sometimes
there is no work for that run.
+For example, a scan-and-repair Dag can return an empty list when it does not
find anything to repair.
+In that case, the mapped task is skipped, and a downstream summary task can
still treat the run as a successful no-op if it uses a trigger rule that allows
skipped upstream tasks.
+
+.. code-block:: python
+
+ from airflow.sdk import TriggerRule, task
+
+
+ @task
+ def find_work_items():
+ # Return an empty list when no files, records, or partitions need
repair.
+ return []
+
+
+ @task
+ def repair(item): ...
+
+
+ @task(trigger_rule=TriggerRule.NONE_FAILED)
+ def summarize(repaired_items):
+ if not repaired_items:
+ print("No work found; nothing to repair.")
+ return
+ print(f"Repaired {len(repaired_items)} item(s).")
+
+
+ repaired_items = repair.expand(item=find_work_items())
+ summarize(repaired_items)