Lee-W commented on code in PR #67717:
URL: https://github.com/apache/airflow/pull/67717#discussion_r3367842616
##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -157,10 +165,52 @@ def dag_clear(args, *, session: Session = NEW_SESSION) ->
None:
query = query.where(DagRun.partition_key == args.partition_key)
else:
query = query.where(DagRun.partition_date.is_not(None))
- if args.partition_date_start is not None:
- query = query.where(DagRun.partition_date >=
args.partition_date_start)
- if args.partition_date_end is not None:
- query = query.where(DagRun.partition_date <=
args.partition_date_end)
+ tt_tz = getattr(dag.timetable, "timezone", None) if
dag.timetable.partitioned else None
+ if tt_tz is not None:
+ # Partitioned runs are stored as local-midnight UTC instants;
compare at day
+ # granularity in the timetable's timezone rather than at the raw
UTC instant.
+ if args.partition_date_start is not None:
+ start_label = args.partition_date_start.date()
Review Comment:
There's actually no day shift here — parsedate keeps a tz-aware value's
offset (the tz= default only applies to naive input), so `.date()` returns the
calendar day as typed.
```python
from airflow._shared.timezones.timezone import parse as parsedate
for s in ["2026-02-19T07:00:00+08:00", "2026-02-19T07:00:00", "2026-02-19"]:
print(f"{s:32} -> .date() = {parsedate(s).date()}")
```
```console
2026-02-19T07:00:00+08:00 -> .date() = 2026-02-19
2026-02-19T07:00:00 -> .date() = 2026-02-19
2026-02-19 -> .date() = 2026-02-19
```
The +08:00 value stays on 2026-02-19 rather than shifting to 2026-02-18, so
time-of-day and offset never change which day is selected. I've reworded the
docstring to say exactly that — only the calendar date is used.
--
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]