Skip to content

feat: ORDER BY ALL #15772

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

feat: ORDER BY ALL #15772

wants to merge 3 commits into from

Conversation

PokIsemaine
Copy link
Contributor

Which issue does this PR close?

  • None

Rationale for this change

What changes are included in this PR?

Added support for ORDER BY ALL syntax

Are these changes tested?

order.slt
test case from https://duckdb.org/docs/stable/sql/query_syntax/orderby.html#order-by-all-examples

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Apr 19, 2025
Comment on lines 704 to 711
/// OrderBy Expressions
pub enum OrderByExprs {
OrderByExprVec(Vec<OrderByExpr>),
All {
exprs: Vec<Expr>,
options: OrderByOptions,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we need the Enum.

Maybe it's enough to wrap Vec<OrderByExpr> as a struct and add an extra flag to indicate the ALL

pub struct OrderByExprs {
    exprs: Vec<OrderByExpr>,
    all: bool
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This requires converting a datafusion_expr::Expr to a SQLExpr, but I'm not sure if there's a good way to do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

this enum seems to only be used in the sql planner, so I don't think it is needed in datafusion-expr -- maybe we can just move this into the datafusion-sql crate and make it pub(crate)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I’ll try to move it this weekend

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @PokIsemaine -- this is a pretty cool feature

@PokIsemaine PokIsemaine marked this pull request as draft May 3, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants