-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix: do not allow grouping sets #4942
fix: do not allow grouping sets #4942
Conversation
fixes: confluentinc#4939 Change to SQL syntax to not allow GROUP BY and PARTITION BY on boolean expressions. Only value expressions will be allowed.
fixes: confluentinc#4941 Change the ksqlDB syntax to now allow grouping sets, which aren't supported yet.
Conflicting files ksqldb-parser/src/main/antlr4/io/confluent/ksql/parser/SqlBase.g4 ksqldb-parser/src/main/java/io/confluent/ksql/parser/AstBuilder.java
@@ -129,7 +129,7 @@ void setWhereExpression(final Expression whereExpression) { | |||
return ImmutableList.copyOf(groupByExpressions); | |||
} | |||
|
|||
void addGroupByExpressions(final Set<Expression> expressions) { | |||
void addGroupByExpressions(final Collection<Expression> expressions) { |
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.
shouldn't grouping expressions be a unique set though ? what does it mean to group by a,a,b,a
? it's possible i'm entirely misunderstanding what this piece of code does though, rusty on this stuff ;) Comment applies regardless of whether the groupingExpression is retained (per Almog's suggestion) or not - i think....
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.
That's a good point Nick. The old code didn't actually enforce this as addGroupByExpressions
was called multiple times.
I've corrected the code and added tests to cover this. Now:
CREATE TABLE OUTPUT AS SELECT COUNT(*) FROM TEST GROUP BY DATA, DATA;
Results in an error:
Duplicate GROUP BY expression: TEST.DATA
The old code was also not maintaining the order of the GROUP BY expressions. This has also been fixed in this PR.
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!
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!
Description
NOTE: this PR is stacked on top of #4940. Only review the second commit onwards.
fixes: #4941
Change the ksqlDB syntax to not allow grouping sets, which aren't supported yet.
This is backwards compatible for already running queries, as they are built from the query plan, not the syntax.
Testing done
usual.
Reviewer checklist