You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/09/10 03:18:07 UTC
[GitHub] [calcite] chunweilei opened a new pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
chunweilei opened a new pull request #2145:
URL: https://github.com/apache/calcite/pull/2145
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] liyafan82 commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486839323
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] chunweilei commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486044687
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
##########
@@ -348,10 +348,13 @@ public Boolean areColumnsUnique(Join rel, RelMetadataQuery mq,
public Boolean areColumnsUnique(Aggregate rel, RelMetadataQuery mq,
ImmutableBitSet columns, boolean ignoreNulls) {
- columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq);
- // group by keys form a unique key
- ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
- return columns.contains(groupKey);
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq);
+ // group by keys form a unique key
+ ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
+ return columns.contains(groupKey);
+ }
+ return false;
Review comment:
Return null seems better(it means unknown). Thank you for your review.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] chunweilei commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486822423
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] liyafan82 commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486839323
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] chunweilei commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486822423
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I don't think so. `rel.getGroupSet()` returns `ImmutableBitSet` while here we should return `Set<ImmutableBitSet>`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] chunweilei merged pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
chunweilei merged pull request #2145:
URL: https://github.com/apache/calcite/pull/2145
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] liyafan82 commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486086238
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
Since the group set is immutable, we can directly return rel.getGroupSet()?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] liyafan82 commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486839323
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdUniqueKeys.java
##########
@@ -246,8 +246,14 @@ private RelMdUniqueKeys() {}
public Set<ImmutableBitSet> getUniqueKeys(Aggregate rel, RelMetadataQuery mq,
boolean ignoreNulls) {
- // group by keys form a unique key
- return ImmutableSet.of(rel.getGroupSet());
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ // group by keys form a unique key
+ return ImmutableSet.of(rel.getGroupSet());
Review comment:
I see. Thanks for the clarification.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] liyafan82 commented on a change in pull request #2145: [CALCITE-4239] RelMdUniqueKeys returns wrong unique keys for Aggregate with grouping sets
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #2145:
URL: https://github.com/apache/calcite/pull/2145#discussion_r486042142
##########
File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
##########
@@ -348,10 +348,13 @@ public Boolean areColumnsUnique(Join rel, RelMetadataQuery mq,
public Boolean areColumnsUnique(Aggregate rel, RelMetadataQuery mq,
ImmutableBitSet columns, boolean ignoreNulls) {
- columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq);
- // group by keys form a unique key
- ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
- return columns.contains(groupKey);
+ if (Aggregate.isSimple(rel) || ignoreNulls) {
+ columns = decorateWithConstantColumnsFromPredicates(columns, rel, mq);
+ // group by keys form a unique key
+ ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
+ return columns.contains(groupKey);
+ }
+ return false;
Review comment:
should we return false or null?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org