Eason09053360 opened a new pull request, #73070:
URL: https://github.com/apache/airflow/pull/73070
## Why
`airflow dags next-execution <dag_id> --field data_interval.start` crashes
with a bare
`AttributeError: 'NoneType' object has no attribute 'start'` on a Dag using
a partitioned
timetable.
`--field` accepts the union of every field any schedule can produce
(`airflow-core/src/airflow/cli/cli_config.py` `ARG_FIELD` choices), so a Dag
can
always be asked for a name its own schedule leaves empty:
`DagRunInfo.data_interval` is
`None` for a partitioned timetable, and
`operator.attrgetter("data_interval.start")` walks
straight into it.
Every neighbouring combination already degrades to `None` instead of raising
— asking a
cron Dag for `--field partition_key` prints `None`, and so does `--field
logical_date` on a
partitioned Dag, which is defined as exactly `data_interval.start if
data_interval else None`.
So the same value crashes under one name and prints `None` under the other.
## What
`airflow-core/src/airflow/cli/commands/dag_command.py` — the `--field` path
now resolves the
dotted name through `_get_schedule_field`, which stops and yields `None` as
soon as the chain
runs out. The `--table` path is unchanged: it picks its column set from
`timetable_partitioned`, so it never asks for a field the Dag cannot have.
Output for every field a Dag's schedule does populate is unchanged.
`airflow-core/tests/unit/cli/commands/test_dag_command.py` — a parametrized
test over
`data_interval.start` / `data_interval.end` against a
`CronPartitionTimetable` Dag, asserting
`None` is printed. Both parametrizations fail with the `AttributeError`
without this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]