thomasrebele commented on code in PR #6523:
URL: https://github.com/apache/hive/pull/6523#discussion_r3603829206


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java:
##########
@@ -517,7 +517,8 @@ private ImmutableBitSet generateNewGroupset(Aggregate 
aggregate, ImmutableBitSet
     RelMetadataQuery mq = aggregate.getCluster().getMetadataQuery();
 
     final Set<ImmutableBitSet> uniqueKeys = mq.getUniqueKeys(input, false);
-    if (uniqueKeys == null || uniqueKeys.isEmpty()) {
+    if (uniqueKeys == null || uniqueKeys.isEmpty() ||
+        (uniqueKeys.size() == 1 && uniqueKeys.iterator().next().isEmpty())) {

Review Comment:
   Small correction: If uniqueKeys is the empty set (uniqueKeys = `{}`), then 
there are no unique keys. If uniqueKeys contains an empty set (e.g., uniqueKeys 
= `{{}}`), then all columns can be considered as unique keys. See 
[BuiltInMetadata.UniqueKeys#getUniqueKeys](https://github.com/apache/calcite/blob/9acb3745c61db9bb01a7427df64cd5d2a0834a96/core/src/main/java/org/apache/calcite/rel/metadata/BuiltInMetadata.java#L133-L134).



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to