Skip to content
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

AIP-84 | Add multisort to dags list request #46383

Open
bbovenzi opened this issue Feb 3, 2025 · 22 comments
Open

AIP-84 | Add multisort to dags list request #46383

bbovenzi opened this issue Feb 3, 2025 · 22 comments
Assignees
Labels
AIP-84 Modern Rest API area:UI Related to UI/UX. For Frontend Developers. good first issue type:new-feature Changelog: New Features

Comments

@bbovenzi
Copy link
Contributor

bbovenzi commented Feb 3, 2025

In the UI, we default the dags list to show dags with the latest dag run first , which we pass as -last_dag_run_start_date. Problem is that the minus symbol seems to make the default sorts also reverse so any dags without a dag run will be in reverse alphabetical order which is counterintuitive for users.
If you reverse the dag run start date order, it will also change the alphabetical order.

Image
@bbovenzi bbovenzi converted this from a draft issue Feb 3, 2025
@dosubot dosubot bot added area:UI Related to UI/UX. For Frontend Developers. kind:bug This is a clearly a bug labels Feb 3, 2025
@pierrejeambrun
Copy link
Member

pierrejeambrun commented Feb 3, 2025

Nice. For now the dag_id (name) is always used as the secondary sort criteria to ensure stability in the result set returned. (In case the primary criteria has identical values).

When we use a descending sort, the secondary filter (which is the primary key of the table, here the dag_id is also .desc()).

In the following code column is the primary sort criteria, the one specified by the user. primary_key_column is the secondary sort criteria always used and retrieved from the models.

if self.value[0] == "-":
return select.order_by(nullscheck, column.desc(), primary_key_column.desc())
else:
return select.order_by(nullscheck, column.asc(), primary_key_column.asc())

I think we need to support multisort to be able to handle this case. Users would be able to specify that they want to sort on the primary criteria in asc(), but on a secondary criteria in desc() order for intance. (Or any other arbitrary combination).

@bbovenzi bbovenzi changed the title AIP-84 | Fix dags list sorting orders with last_dag_run_start_date AIP-84 | Add multisort to dags list request Feb 3, 2025
@vikramkoka vikramkoka added the AIP-84 Modern Rest API label Feb 3, 2025
@Vishnu-sai-teja
Copy link

Hey can work on this.

@pierrejeambrun
Copy link
Member

Great, assigned !

@phanikumv phanikumv moved this from Todo to In Progress in AIP-84 MODERN REST API Feb 6, 2025
@prasad-madine
Copy link

Hello @pierrejeambrun, Are both front-end and back-end changes being done by the assignee?

@pierrejeambrun
Copy link
Member

Hello @prasad-madine, I assume so.

We need the backend contribution to start working on the front-end anyway.

@Vishnu-sai-teja any progress ? Do you have plan on following up with the front-end changes as well ?

@Vishnu-sai-teja
Copy link

Hey out of town, haven't started on it yet, Sorry I should have informed earlier

@bbovenzi
Copy link
Contributor Author

The UI part should be fairly straightforward: https://tanstack.com/table/latest/docs/guide/sorting#multi-sorting

@prasad-madine
Copy link

Hello @pierrejeambrun ,
I am currently working on implementing sorting functionality in the backend and would appreciate your guidance on the following two approaches:

Option 1

  1. Allow user to select the primary sort field and order(asc/desc)
  2. Allow user to select the secondary sort field and order(asc/desc)
  3. Allow user to select which field is primary and which field is secondary

Option 2

  1. Allow user to select the primary sort field and order(asc/desc)
  2. Do not allow user to select the secondary sort field. Secondary sort field is always primary key.
  3. Allow user to select the order in which we sort based on primary key.

Could you please advise on which option would be more appropriate or effective in this context?

@bbovenzi
Copy link
Contributor Author

I would say option 1. The sort param would be passed in the url like so: order_by=-run-after&order_by=dag_display_name

The primary sort should be the first order_by param passed. Secondary sort, the second param.

@pierrejeambrun
Copy link
Member

I would say option 1. The sort param would be passed in the url like so: order_by=-run-after&order_by=dag_display_name

The primary sort should be the first order_by param passed. Secondary sort, the second param.

That's also what I had in mind.

prasad-madine added a commit to prasad-madine/airflow that referenced this issue Mar 6, 2025
@prasad-madine
Copy link

Hello @bbovenzi @pierrejeambrun , I've implemented the backend code in below PR, Could you please review that.
#47440
Thankyou.

@pierrejeambrun pierrejeambrun added type:new-feature Changelog: New Features and removed kind:bug This is a clearly a bug labels Mar 6, 2025
@mariana-marcal-santana
Copy link

Hello @bbovenzi @pierrejeambrun ! I'm a senior CS and engineering student and i would love to contribute to the frontend part of this issue for a project for one of my final classes. Would that be possible?

@pierrejeambrun
Copy link
Member

@mariana-marcal-santana you can follow along the backend change #47440.

@prasad-madine were you planning on following up with the frontend once you are done with the backend or do you want @mariana-marcal-santana to take this work ?

@prasad-madine
Copy link

@mariana-marcal-santana you can follow along the backend change #47440.

@prasad-madine were you planning on following up with the frontend once you are done with the backend or do you want @mariana-marcal-santana to take this work ?

Yeah @mariana-marcal-santana can work on frontend portion.
Thanks

@pierrejeambrun
Copy link
Member

@mariana-marcal-santana you'r also assigned

prasad-madine added a commit to prasad-madine/airflow that referenced this issue Mar 14, 2025
@mariana-marcal-santana
Copy link

Hello @bbovenzi @pierrejeambrun ! I've been working on the frontend of this issue and I believe I'm in the right track to solve it. However, I have a few things that I would like to confirm.
I followed the instructions on the link provided here #46383 (comment) to implement the multisort in the DAG table and now it's possible to define more sort parameters in the URL, as shown in the picture bellow.

Image

As seen in the picture, the DAGs should be sorted firstly by "last_run_start_date" (OK) and secondly by "-dag_id" (not OK) because they appear sorted by "dag_id". Given this, I'm not sure where my implementation could be going wrong or if it's something related to the backend. @prasad-madine sorry to bother but could you take a look into this case please?
I also wanted to point out that the parameters are mentioned in the URL as "sort=" and not "order_by=" like mentioned here #46383 (comment). I'm not sure if that would be a problem, especially because since I've been working on this issue, they've always appeared as "sort=" in the UI but I would appreciate it if someone could confirm that.
Thank you!

mariana-marcal-santana added a commit to mariana-marcal-santana/airflow that referenced this issue Mar 17, 2025
Frontend: Implement multisort for DAGs when displayed in a table;
The URL displays extra sorting attributes when Shift+"click" is used
on the column to sort by.
mariana-marcal-santana added a commit to mariana-marcal-santana/airflow that referenced this issue Mar 17, 2025
Frontend: Implement multisort for DAGs when displayed in a table;
The URL displays extra sorting attributes when Shift+click is used
on the column to sort by.

This implements the UI portion of apache#46383
@pierrejeambrun
Copy link
Member

pierrejeambrun commented Mar 17, 2025

@mariana-marcal-santana Thanks, looking good.

#47859 (backend) has not been merged into main yet, are you building your PR on top of #47859 ? Otherwise you will need to wait for the backend to be completed (it is not supported yet).

@pierrejeambrun
Copy link
Member

pierrejeambrun commented Mar 17, 2025

I'm not sure if that would be a problem, especially because since I've been working on this issue, they've always appeared as "sort=" in the UI but I would appreciate it if someone could confirm that.

Indeed, in the url we use sort and the front-end converts this to order_by before sending the request to the backend. (I don't know why we just didn't use orderBy too in the url, but just to answer your question, this is expected and shouldn't be a problem.)

@mariana-marcal-santana
Copy link

#47859 (backend) has not been merged into main yet, are you building your PR on top of #47859 ? Otherwise you will need to wait for the backend to be completed (it is not supported yet).

For the multisort to fully work it needs the #47440's backend but I tested locally my changes by themselves and they don't break the platform even without the corresponding backend. I don't mind waiting for the backend and if anything is needed I would be happy to help!

Also, maybe I didn't fully understand the question but I don't know much about the PR mentioned in the comment and if it has any effect on mine...

@mariana-marcal-santana
Copy link

Indeed, in the url we use sort and the front-end converts this to order_by before sending the request to the backend. (I don't know why we just didn't use orderBy too in the url, but just to answer your question, this is expected and shouldn't be a problem.)

Thanks for clearing that out!

mariana-marcal-santana added a commit to mariana-marcal-santana/airflow that referenced this issue Mar 21, 2025
Frontend: Implement multisort for DAGs when displayed in a table;
The browser and backend URLs display extra sorting attributes when
Shift+click is used on the column to sort by.
mariana-marcal-santana added a commit to mariana-marcal-santana/airflow that referenced this issue Mar 21, 2025
Frontend: Implement multisort for DAGs when displayed in a table;
The browser and backend URLs display extra sorting attributes when
Shift+click is used on the column to sort by.
This implements the UI portion of apache#46383
prasad-madine added a commit to prasad-madine/airflow that referenced this issue Mar 26, 2025
@mariana-marcal-santana
Copy link

Hello @bbovenzi @pierrejeambrun !
Have you gotten a chance to look at the fixes from last commit?
Thanks

@pierrejeambrun
Copy link
Member

Hello @mariana-marcal-santana,

Sorry for the delay, I just did a review, it will be easier to test and iterate once the backend is merged, we're working on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-84 Modern Rest API area:UI Related to UI/UX. For Frontend Developers. good first issue type:new-feature Changelog: New Features
Projects
Status: In Progress
Development

No branches or pull requests

6 participants