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

fix: do not allow grouping sets #4942

Merged
merged 4 commits into from
Mar 31, 2020

Conversation

big-andy-coates
Copy link
Contributor

@big-andy-coates big-andy-coates commented Mar 30, 2020

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

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

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.
@big-andy-coates big-andy-coates requested a review from a team as a code owner March 30, 2020 20:32
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) {
Copy link
Contributor

@blueedgenick blueedgenick Mar 31, 2020

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....

Copy link
Contributor Author

@big-andy-coates big-andy-coates Mar 31, 2020

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

LGTM!

@big-andy-coates big-andy-coates merged commit 51bb9f6 into confluentinc:master Mar 31, 2020
@big-andy-coates big-andy-coates deleted the drop_group_sets branch March 31, 2020 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ksqlDB allows, but ignores, grouping sets
3 participants