-
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
Merged
big-andy-coates
merged 4 commits into
confluentinc:master
from
big-andy-coates:drop_group_sets
Mar 31, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fd35b13
fix: do not allow GROUP BY and PARTITION BY on boolean expressions
big-andy-coates 17833d2
fix: do not allow grouping sets
big-andy-coates 27ca851
chore: merge from master
big-andy-coates 4547667
chore: changes requested by Nick
big-andy-coates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
...l_plans/group-by_-_with_single_grouping_set_(stream-_table)/6.0.0_1585599970057/plan.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
{ | ||
"plan" : [ { | ||
"@type" : "ksqlPlanV1", | ||
"statementText" : "CREATE STREAM TEST (ROWKEY INTEGER KEY, F1 INTEGER, F2 STRING, F3 INTEGER) WITH (KAFKA_TOPIC='test_topic', KEY='f1', VALUE_FORMAT='DELIMITED');", | ||
"ddlCommand" : { | ||
"@type" : "createStreamV1", | ||
"sourceName" : "TEST", | ||
"schema" : "`ROWKEY` INTEGER KEY, `F1` INTEGER, `F2` STRING, `F3` INTEGER", | ||
"keyField" : "F1", | ||
"topicName" : "test_topic", | ||
"formats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
} | ||
} | ||
}, { | ||
"@type" : "ksqlPlanV1", | ||
"statementText" : "CREATE TABLE OUTPUT AS SELECT\n TEST.F1 F1,\n TEST.F2 F2,\n COUNT(*) KSQL_COL_0\nFROM TEST TEST\nGROUP BY TEST.F3, TEST.F2, TEST.F1\nEMIT CHANGES", | ||
"ddlCommand" : { | ||
"@type" : "createTableV1", | ||
"sourceName" : "OUTPUT", | ||
"schema" : "`ROWKEY` STRING KEY, `F1` INTEGER, `F2` STRING, `KSQL_COL_0` BIGINT", | ||
"topicName" : "OUTPUT", | ||
"formats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
} | ||
}, | ||
"queryPlan" : { | ||
"sources" : [ "TEST" ], | ||
"sink" : "OUTPUT", | ||
"physicalPlan" : { | ||
"@type" : "tableSinkV1", | ||
"properties" : { | ||
"queryContext" : "OUTPUT" | ||
}, | ||
"source" : { | ||
"@type" : "tableSelectV1", | ||
"properties" : { | ||
"queryContext" : "Aggregate/Project" | ||
}, | ||
"source" : { | ||
"@type" : "streamAggregateV1", | ||
"properties" : { | ||
"queryContext" : "Aggregate/Aggregate" | ||
}, | ||
"source" : { | ||
"@type" : "streamGroupByV1", | ||
"properties" : { | ||
"queryContext" : "Aggregate/GroupBy" | ||
}, | ||
"source" : { | ||
"@type" : "streamSelectV1", | ||
"properties" : { | ||
"queryContext" : "Aggregate/Prepare" | ||
}, | ||
"source" : { | ||
"@type" : "streamSourceV1", | ||
"properties" : { | ||
"queryContext" : "KsqlTopic/Source" | ||
}, | ||
"topicName" : "test_topic", | ||
"formats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
}, | ||
"sourceSchema" : "`ROWKEY` INTEGER KEY, `F1` INTEGER, `F2` STRING, `F3` INTEGER" | ||
}, | ||
"selectExpressions" : [ "F1 AS F1", "F2 AS F2", "ROWTIME AS ROWTIME", "F3 AS F3" ] | ||
}, | ||
"internalFormats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
}, | ||
"groupByExpressions" : [ "F3", "F2", "F1" ] | ||
}, | ||
"internalFormats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
}, | ||
"nonAggregateColumns" : [ "F1", "F2", "ROWTIME", "F3" ], | ||
"aggregationFunctions" : [ "COUNT(ROWTIME)" ] | ||
}, | ||
"selectExpressions" : [ "F1 AS F1", "F2 AS F2", "KSQL_AGG_VARIABLE_0 AS KSQL_COL_0" ] | ||
}, | ||
"formats" : { | ||
"keyFormat" : { | ||
"format" : "KAFKA" | ||
}, | ||
"valueFormat" : { | ||
"format" : "DELIMITED" | ||
} | ||
}, | ||
"topicName" : "OUTPUT" | ||
}, | ||
"queryId" : "CTAS_OUTPUT_0" | ||
} | ||
} ], | ||
"configs" : { | ||
"ksql.extension.dir" : "ext", | ||
"ksql.streams.cache.max.bytes.buffering" : "0", | ||
"ksql.security.extension.class" : null, | ||
"ksql.transient.prefix" : "transient_", | ||
"ksql.persistence.wrap.single.values" : "true", | ||
"ksql.authorization.cache.expiry.time.secs" : "30", | ||
"ksql.schema.registry.url" : "", | ||
"ksql.streams.default.deserialization.exception.handler" : "io.confluent.ksql.errors.LogMetricAndContinueExceptionHandler", | ||
"ksql.output.topic.name.prefix" : "", | ||
"ksql.streams.auto.offset.reset" : "earliest", | ||
"ksql.query.pull.enable.standby.reads" : "false", | ||
"ksql.connect.url" : "http://localhost:8083", | ||
"ksql.service.id" : "some.ksql.service.id", | ||
"ksql.internal.topic.min.insync.replicas" : "1", | ||
"ksql.streams.shutdown.timeout.ms" : "300000", | ||
"ksql.internal.topic.replicas" : "1", | ||
"ksql.insert.into.values.enabled" : "true", | ||
"ksql.query.pull.max.allowed.offset.lag" : "9223372036854775807", | ||
"ksql.streams.default.production.exception.handler" : "io.confluent.ksql.errors.ProductionExceptionHandlerUtil$LogAndFailProductionExceptionHandler", | ||
"ksql.access.validator.enable" : "auto", | ||
"ksql.streams.bootstrap.servers" : "localhost:0", | ||
"ksql.streams.commit.interval.ms" : "2000", | ||
"ksql.metric.reporters" : "", | ||
"ksql.query.pull.metrics.enabled" : "false", | ||
"ksql.authentication.plugin.class" : null, | ||
"ksql.streams.auto.commit.interval.ms" : "0", | ||
"ksql.metrics.extension" : null, | ||
"ksql.streams.topology.optimization" : "all", | ||
"ksql.hidden.topics" : "_confluent.*,__confluent.*,_schemas,__consumer_offsets,__transaction_state,connect-configs,connect-offsets,connect-status,connect-statuses", | ||
"ksql.streams.num.stream.threads" : "4", | ||
"ksql.timestamp.throw.on.invalid" : "false", | ||
"ksql.authorization.cache.max.entries" : "10000", | ||
"ksql.metrics.tags.custom" : "", | ||
"ksql.pull.queries.enable" : "true", | ||
"ksql.udfs.enabled" : "true", | ||
"ksql.udf.enable.security.manager" : "true", | ||
"ksql.connect.worker.config" : "", | ||
"ksql.any.key.name.enabled" : "false", | ||
"ksql.sink.window.change.log.additional.retention" : "1000000", | ||
"ksql.readonly.topics" : "_confluent.*,__confluent.*,_schemas,__consumer_offsets,__transaction_state,connect-configs,connect-offsets,connect-status,connect-statuses", | ||
"ksql.udf.collect.metrics" : "false", | ||
"ksql.persistent.prefix" : "query_", | ||
"ksql.query.persistent.active.limit" : "2147483647" | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...l_plans/group-by_-_with_single_grouping_set_(stream-_table)/6.0.0_1585599970057/spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"version" : "6.0.0", | ||
"timestamp" : 1585599970057, | ||
"schemas" : { | ||
"CTAS_OUTPUT_0.KsqlTopic.Source" : "STRUCT<F1 INT, F2 VARCHAR, F3 INT> NOT NULL", | ||
"CTAS_OUTPUT_0.Aggregate.GroupBy" : "STRUCT<F1 INT, F2 VARCHAR, ROWTIME BIGINT, F3 INT> NOT NULL", | ||
"CTAS_OUTPUT_0.Aggregate.Aggregate.Materialize" : "STRUCT<F1 INT, F2 VARCHAR, ROWTIME BIGINT, F3 INT, KSQL_AGG_VARIABLE_0 BIGINT> NOT NULL", | ||
"CTAS_OUTPUT_0.OUTPUT" : "STRUCT<F1 INT, F2 VARCHAR, KSQL_COL_0 BIGINT> NOT NULL" | ||
}, | ||
"inputs" : [ { | ||
"topic" : "test_topic", | ||
"key" : 1, | ||
"value" : "1,a,-1" | ||
}, { | ||
"topic" : "test_topic", | ||
"key" : 2, | ||
"value" : "2,b,-2" | ||
}, { | ||
"topic" : "test_topic", | ||
"key" : 1, | ||
"value" : "1,a,-1" | ||
}, { | ||
"topic" : "test_topic", | ||
"key" : 2, | ||
"value" : "2,b,-2" | ||
}, { | ||
"topic" : "test_topic", | ||
"key" : 3, | ||
"value" : "3,a,-3" | ||
} ], | ||
"outputs" : [ { | ||
"topic" : "OUTPUT", | ||
"key" : "-1|+|a|+|1", | ||
"value" : "1,a,1" | ||
}, { | ||
"topic" : "OUTPUT", | ||
"key" : "-2|+|b|+|2", | ||
"value" : "2,b,1" | ||
}, { | ||
"topic" : "OUTPUT", | ||
"key" : "-1|+|a|+|1", | ||
"value" : "1,a,2" | ||
}, { | ||
"topic" : "OUTPUT", | ||
"key" : "-2|+|b|+|2", | ||
"value" : "2,b,2" | ||
}, { | ||
"topic" : "OUTPUT", | ||
"key" : "-3|+|a|+|3", | ||
"value" : "3,a,1" | ||
} ], | ||
"postConditions" : { | ||
"sources" : [ { | ||
"name" : "OUTPUT", | ||
"type" : "table", | ||
"schema" : "ROWKEY STRING KEY, F1 INT, F2 STRING, KSQL_COL_0 BIGINT" | ||
} ] | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Results in an error:
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!