-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Add Advance Search Support and Integrate with Get Variables #44516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Advance Search Support and Integrate with Get Variables #44516
Conversation
| STARTS_WITH = "starts_with" | ||
| ENDS_WITH = "ends_with" | ||
| CONTAINS = "contains" | ||
| EQUALS = "equals" | ||
| NOT_STARTS_WITH = "not_starts_with" | ||
| NOT_ENDS_WITH = "not_ends_with" | ||
| NOT_CONTAINS = "not_contains" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what's the best way to pass all these filter options to the UI so we can build the proper form for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can have a dropdown and multiple lines of search can be given from user with add and delete functionality for each search options.
Similar behaviour from legacy UI
const filters = [
{ key: "STARTS_WITH", label: "Starts With", value: "starts_with" },
{ key: "ENDS_WITH", label: "Ends With", value: "ends_with" },
{ key: "CONTAINS", label: "Contains", value: "contains" },
{ key: "EQUALS", label: "Equals", value: "equals" },
{ key: "NOT_STARTS_WITH", label: "Does Not Start With", value: "not_starts_with" },
{ key: "NOT_ENDS_WITH", label: "Does Not End With", value: "not_ends_with" },
{ key: "NOT_CONTAINS", label: "Does Not Contain", value: "not_contains" }
];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a private endpoint for that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also an endpoint to list resource fields, and their types, so we can appropriately display the UI form.
For instance DAGModel has a field called is_active which is a boolean etc.. etc.... (So we can basically list fields, operators, and then compos fields + operators do construct a dynamic query)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by private, do you mean ui endpoint?
Yes, I completely agree we should have a endpoint to list the applicable columns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We need an endpoint to list possible operations (in, or, and, >= etc...) and the columns that can be used and maybe the 'type' as well. (boolean, number, etc.)
pierrejeambrun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
| return depends_search | ||
|
|
||
|
|
||
| class SearchPatternEnum(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should reuse FilterOptionEnum and rename it to a more generic name. Maybe move it to the DB package with something like ORMOperatorEnum or something else.
DB operations supported by the query parameters and the one from advanced search will basically be very close. (and this will avoid duplication).
As we do for states task_states dag_run_states, etc.. we can split FilterOperator AdvancedSearchOperator, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FilterOptionEnum have bit different types of support, such as numeric, etc.
Mixing both could create confusion?
Maybe i can differentiate this with filter, such that it should actually look like advance search, like chnaging filter param to advance_search in APIs.
Also do you mean something like:
Parent : child?
ORMOperator -> FilterOperator, AdvancedSearchOperator ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the enumeration of all ORM operation could live in the db module of FastAPI.
Then other enums FilterOperator, AdvancedSearchOperator can use that, but basically Filter and Search are just query params, the difference is the db operator that is used airflow/utils/states.py combines enums as well, could be interesting to take a look.
That's not of big importance at this stage I think
| STARTS_WITH = "starts_with" | ||
| ENDS_WITH = "ends_with" | ||
| CONTAINS = "contains" | ||
| EQUALS = "equals" | ||
| NOT_STARTS_WITH = "not_starts_with" | ||
| NOT_ENDS_WITH = "not_ends_with" | ||
| NOT_CONTAINS = "not_contains" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a private endpoint for that ?
| pattern_map = { | ||
| SearchPatternEnum.STARTS_WITH: f"{self.value}%", | ||
| SearchPatternEnum.ENDS_WITH: f"%{self.value}", | ||
| SearchPatternEnum.CONTAINS: f"%{self.value}%", | ||
| SearchPatternEnum.EQUALS: self.value, | ||
| SearchPatternEnum.NOT_STARTS_WITH: f"{self.value}%", | ||
| SearchPatternEnum.NOT_ENDS_WITH: f"%{self.value}", | ||
| SearchPatternEnum.NOT_CONTAINS: f"%{self.value}%", | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All that is really focused around search (text search) while I imagined advanced search to actually be on any field and any db operation.
For instance I want a custom query to display dags with the specific status that is SUCCESS and with the dag_id that ends with something and is_paused True.
Basically serializing and deserializing via a query parameter &query='xxxxx'&query='' dyanamic Filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that,
Maybe I might be wrong, I would need some clarity about the differences between filter and advance_search operations.
If advance_search starts taking for booleans or special types, wouldn't it contradict the work of filters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we eventually want is the ability to create a full custom query such as:
I want dags that are in success or running state, and that have a dag_id that starts with dag_id_prefix and with at least 1 tag among [tag1, tag2].
Its basically being able to create a custom query.
Also I think we need to be able to support 'AND' and 'OR' and maybe composition (cd1 | cd2) & (cd3).
| STARTS_WITH = "starts_with" | ||
| ENDS_WITH = "ends_with" | ||
| CONTAINS = "contains" | ||
| EQUALS = "equals" | ||
| NOT_STARTS_WITH = "not_starts_with" | ||
| NOT_ENDS_WITH = "not_ends_with" | ||
| NOT_CONTAINS = "not_contains" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also an endpoint to list resource fields, and their types, so we can appropriately display the UI form.
For instance DAGModel has a field called is_active which is a boolean etc.. etc.... (So we can basically list fields, operators, and then compos fields + operators do construct a dynamic query)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to extend this to 'any' column of the resource and 'any' operation. (>=, text contains start with end with etc.., IN, array contain etc..)
Maybe the serialization form should be something like
?query="((key, START_WITH, 'something') or (value, EQUAL, 'some_value')) and (value, END_WITH, 'suffix')"
Maybe we don't need OR | AND support and expressions (nested boolean operators). Maybe we don't need full flexibility about fields and filters used. Because if it's just some predetermined filters, we can just develop them as we do currently and add an endpoint to retrieve them (types, possible values etc...) and display that directly in the UI, constructing the current query normaly with in the front-end ?state=success&active=true.
Maybe @bbovenzi can confirm the use case.
| STARTS_WITH = "starts_with" | ||
| ENDS_WITH = "ends_with" | ||
| CONTAINS = "contains" | ||
| EQUALS = "equals" | ||
| NOT_STARTS_WITH = "not_starts_with" | ||
| NOT_ENDS_WITH = "not_ends_with" | ||
| NOT_CONTAINS = "not_contains" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We need an endpoint to list possible operations (in, or, and, >= etc...) and the columns that can be used and maybe the 'type' as well. (boolean, number, etc.)
| pattern_map = { | ||
| SearchPatternEnum.STARTS_WITH: f"{self.value}%", | ||
| SearchPatternEnum.ENDS_WITH: f"%{self.value}", | ||
| SearchPatternEnum.CONTAINS: f"%{self.value}%", | ||
| SearchPatternEnum.EQUALS: self.value, | ||
| SearchPatternEnum.NOT_STARTS_WITH: f"{self.value}%", | ||
| SearchPatternEnum.NOT_ENDS_WITH: f"%{self.value}", | ||
| SearchPatternEnum.NOT_CONTAINS: f"%{self.value}%", | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we eventually want is the ability to create a full custom query such as:
I want dags that are in success or running state, and that have a dag_id that starts with dag_id_prefix and with at least 1 tag among [tag1, tag2].
Its basically being able to create a custom query.
Also I think we need to be able to support 'AND' and 'OR' and maybe composition (cd1 | cd2) & (cd3).
| # Variables | ||
| VARIABLE_COLUMN_MAP = { | ||
| "key": Variable.key, | ||
| "value": Variable._val, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to use the val proxy not directly _val
|
Note: As PR #45312 has been merged, the code formatting rules have changed for new UI. Please rebase and re-run pre-commit checks to ensure that formatting in folder airflow/ui is adjusted. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
Add the filter variables support
Request:

Response:

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.