镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading