Skip to content

Conversation

@comphead
Copy link
Contributor

Which issue does this PR close?

Closes #8386 .

Rationale for this change

Support scalars for PARTITION BY clause to avoid Expects PARTITION BY expression to be ordered error.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions bot added sql SQL Planner sqllogictest SQL Logic Tests (.slt) labels Dec 15, 2023
@comphead
Copy link
Contributor Author

@mustafasrepo please review

Copy link
Contributor

@mustafasrepo mustafasrepo left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @comphead. I have one minor comment. However It is not important for this PR.

.filter(|e| !matches!(e, sqlparser::ast::Expr::Value { .. },))
.map(|e| self.sql_expr_to_logical_expr(e, schema, planner_context))
.collect::<Result<Vec<_>>>()?;
let mut order_by = self.order_by_to_sort_expr(
Copy link
Contributor

Choose a reason for hiding this comment

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

According to test it seems that we have no problem with ScalarValues inside window order_by. However, I think we can apply similar filtering done for window.partition_by to the window.order_by.

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.

Looks good to me -- thank you @comphead and @mustafasrepo

1
1

# support scalar value in both ORDER BY and PARTITION BY, RANK function
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 as @mustafasrepo points out

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

Labels

sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: windows frame don't support scalars in ORDER BY/PARTITION BY clauses

3 participants