pierrejeambrun commented on code in PR #54263:
URL: https://github.com/apache/airflow/pull/54263#discussion_r2270494959
##########
airflow-core/src/airflow/api_fastapi/common/parameters.py:
##########
@@ -606,6 +606,65 @@ def depends_float(
QueryTagsFilter = Annotated[_TagsFilter, Depends(_TagsFilter.depends)]
QueryOwnersFilter = Annotated[_OwnersFilter, Depends(_OwnersFilter.depends)]
+
+class _HasAssetScheduleFilter(BaseParam[bool]):
+ """Filter DAGs that have asset-based scheduling."""
+
+ def to_orm(self, select: Select) -> Select:
+ if self.value is None and self.skip_none:
+ return select
+
+ if self.value:
+ # Filter DAGs that have asset-based scheduling
+ return select.where(
+ and_(
+ DagModel.asset_expression.is_not(None),
+ func.cast(DagModel.asset_expression, String) != "null",
Review Comment:
I didn't mean that to add a comment, but to find a way to not have to hard
cast to `String`. Casting to string seems hacky.
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py:
##########
@@ -367,7 +395,16 @@ def test_get_dags(self, test_client, query_params,
expected_total_entries, expec
body = response.json()
assert body["total_entries"] == expected_total_entries
- assert [dag["dag_id"] for dag in body["dags"]] == expected_ids
+ actual_ids = [dag["dag_id"] for dag in body["dags"]]
+
+ # For asset filter tests (but not sort tests), order doesn't matter,
so use set comparison
+ if (
+ any(param in query_params for param in ["has_asset_schedule",
"asset_dependency"])
+ and "order_by" not in query_params
+ ):
+ assert set(actual_ids) == set(expected_ids)
+ else:
+ assert actual_ids == expected_ids
Review Comment:
Order always matter, even if order is not explicitly specified by the user
the API defaults to a primary key ordering. SO results should always be
deterministic
This is important and we should keep enforcing it.
--
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]