github-actions[bot] opened a new pull request, #67102:
URL: https://github.com/apache/airflow/pull/67102
* fix(api): replace COALESCE with index-friendly OR conditions in datetime
range filters
Adds NullableDatetimeRangeFilter, a RangeFilter subclass for
start_date/end_date
columns that emits OR predicates instead of COALESCE(col, now()), allowing
PostgreSQL to use btree indexes on those columns.
Two bugs fixed versus the original implementation in PR #66696:
- Lower bounds now use or_(col >= x, col.is_(None)) without a now() guard,
so future-scheduled tasks (NULL start_date) are never incorrectly excluded.
- The factory dispatches on (attribute_name or filter_name), so aliased
callers
like datetime_range_filter_factory("dag_run_end_date", DagRun, "end_date")
also receive NullableDatetimeRangeFilter rather than a plain RangeFilter.
* fix(api): scope NullableDatetimeRangeFilter to filter_name, not
attribute_name
datetime_range_filter_factory("dag_run_start_date", DagRun, "start_date")
passes attribute_name="start_date", so the guard
if (attribute_name or filter_name) in ("start_date", "end_date"):
resolved to "start_date" and incorrectly returned NullableDatetimeRangeFilter
for the dag_run_start/end_date filters in the DAGs route. Those columns are
reached via an outer join; NULL means "no run", not "currently running", so
the OR (col IS NULL) branch inflated total_entries counts.
The original COALESCE guard checked filter_name only, so "dag_run_start_date"
was excluded. Revert to filter_name to preserve those semantics — only
callers with filter_name="start_date" or "end_date" (task instances, dag_run,
job routes) get NullableDatetimeRangeFilter.
Fixes TestGetDags::test_get_dags failures for query_params 13/14/17/21/23.
* fix(tests): correct test_aliased_*_returns_nullable_filter assertions
The dag_run_start_date and dag_run_end_date filters in the DAGs route use
an outer join, so NULL means "the DAG has no runs" — not "currently running".
They must return a plain RangeFilter, not NullableDatetimeRangeFilter.
Replace the two tests that incorrectly expected NullableDatetimeRangeFilter
for aliased callers with tests that assert plain RangeFilter is returned.
(cherry picked from commit 37667f11aa37eb27072a79b2de1d5dbec09c2218)
Co-authored-by: Hemkumar Chheda <[email protected]>
--
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]