Skip to content

Conversation

@Jkhall81
Copy link
Contributor

@Jkhall81 Jkhall81 commented Jan 1, 2026

feat(api_fastapi): support OR operator in search parameters

closes: #59545

Summary

This PR introduces support for the OR operator using the pipe (|) character in the FastAPI-based Airflow 3.0 API. By updating the centralized _SearchParam logic, this functionality is enabled across multiple entities including DAGs, Dag Runs, and Task Instances.

Changes

  • Backend: Modified _SearchParam.to_orm in parameters.py to parse search terms separated by | and wrap them in a sqlalchemy.or_ condition.
  • Documentation: Updated the DESCRIPTION in search_param_factory to inform users of the new syntax in the API documentation.
  • Tests: Added unit tests in test_parameters.py to verify SQL generation for both single-term and multi-term searches.
@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. labels Jan 1, 2026
@Jkhall81
Copy link
Contributor Author

Jkhall81 commented Jan 1, 2026

There are two failures in the CI, but they appear to be unrelated to the code changes:

  1. tests/airflowctl_tests/test_airflowctl_commands.py: Fails with an AssertionError on dags pause due to a missing positional argument. It seems to be a mismatch between the CLI and the integration test on the current main branch.

  2. providers/microsoft/azure/tests/unit/microsoft/azure/triggers/test_wasb.py: This is an asyncio task assertion failure with the Azure provider.

My code changes were in airflow-core/src/airflow/api_fastapi/common/parameters.py and the corresponding unit tests, including the new ones, are passing.

@potiuk potiuk force-pushed the features/fastapi-or-search-59545 branch from 5616b93 to c3dc23d Compare January 1, 2026 09:06
@potiuk
Copy link
Member

potiuk commented Jan 1, 2026

In case something like that happens - just rebase next time.

ABR -> Always Be Rebased.

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! LGTM overall.

Not sure whether @pierrejeambrun will have any comment for the current public interface change? I will defer to him for the final call.

Comment on lines +112 to +125
sql = str(statement.compile(compile_kwargs={"literal_binds": True})).lower()
assert "dag_id" in sql
assert "like" in sql

def test_to_orm_multiple_values_or(self):
"""Test search with multiple terms using the pipe | operator."""
param = _SearchParam(DagModel.dag_id).set_value("example_bash | example_python")
statement = select(DagModel)
statement = param.to_orm(statement)

sql = str(statement.compile(compile_kwargs={"literal_binds": True}))
assert "OR" in sql
assert "example_bash" in sql
assert "example_python" in sql
Copy link
Member

@jason810496 jason810496 Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit: How about asserting the whole expected SQL statement as str for better readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I went with the keyword assertions because I thought asserting the full compiled SQL string might make the test brittle / requre maintenance in the future. If the SQLAlchemy version changes its formatting or if we run tests against different DB dialects, then a hardcoded string could cause failures. By checking for the presence of the OR operator and the specific search terms used, we can verify the logic and keep the test robust. What do you think?

@Jkhall81
Copy link
Contributor Author

Jkhall81 commented Jan 1, 2026

Just wanted to say this is by far the coolest project I've contributed to so far. The pre-commit system and the automation you guys have set up is incredible. It's been a great learning experience. Also really appreciate how active and responsive the community is here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers.

3 participants