-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
minor: fix to support scalars #8559
Conversation
@mustafasrepo please review |
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.
LGTM! Thanks @comphead. I have one minor comment. However It is not important for this PR.
@@ -90,6 +90,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { | |||
let partition_by = window | |||
.partition_by | |||
.into_iter() | |||
//ignore window spec PARTITION BY for scalar values | |||
.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( |
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.
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
.
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.
Looks good to me -- thank you @comphead and @mustafasrepo
query I | ||
select rank() over (order by 1) rnk from (select 1 a union all select 2 a) x | ||
---- | ||
1 | ||
1 | ||
|
||
# support scalar value in both ORDER BY and PARTITION BY, RANK function |
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.
👍 as @mustafasrepo points out
Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
Closes #8386 .
Rationale for this change
Support scalars for
PARTITION BY
clause to avoidExpects 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