okumin commented on code in PR #5409:
URL: https://github.com/apache/hive/pull/5409#discussion_r1818929701


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java:
##########
@@ -158,8 +158,57 @@ public Object process(Node nd, Stack<Node> stack, 
NodeProcessorCtx procCtx,
         }
       }
 
-      listBucketCols.add(bucketCols);
-      OpTraits opTraits = new OpTraits(listBucketCols, numBuckets,
+      final List<List<String>> listBucketCols = new ArrayList<>();
+      final List<CustomBucketFunction> bucketFunctions = new ArrayList<>();
+      final int numBuckets;
+      if (parentOpTraits == null || !parentOpTraits.hasCustomBucketFunction()) 
{
+        // No CustomBucketFunctions
+        listBucketCols.add(bucketCols);
+        bucketFunctions.add(null);
+        numBuckets = parentOpTraits == null ? -1 : 
parentOpTraits.getNumBuckets();
+      } else if (parentOpTraits.getCustomBucketFunctions().size() > 1) {
+        // We don't know how to merge multiple custom bucket functions. Reset 
bucket attributes
+        Preconditions.checkState(parentOpTraits.getBucketColNames().size() > 
1);
+        listBucketCols.add(Collections.emptyList());
+        bucketFunctions.add(null);
+        numBuckets = -1;
+      } else {
+        Preconditions.checkState(parentOpTraits.getBucketColNames().size() == 
1);
+        
Preconditions.checkState(parentOpTraits.getCustomBucketFunctions().size() == 1);
+        final Map<String, String> inputToOutput = rs
+            .getColumnExprMap()
+            .entrySet()
+            .stream()
+            .filter(entry -> entry.getValue() instanceof ExprNodeColumnDesc)
+            .filter(entry -> 
rs.getConf().getKeyCols().stream().anyMatch(keyDesc -> 
keyDesc.isSame(entry.getValue())))

Review Comment:
   Yes, we can if we implement a Set identifying elements by 
`ExprNodeDesc#isSame`. I didn't do it here



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java:
##########
@@ -158,8 +158,57 @@ public Object process(Node nd, Stack<Node> stack, 
NodeProcessorCtx procCtx,
         }
       }
 
-      listBucketCols.add(bucketCols);
-      OpTraits opTraits = new OpTraits(listBucketCols, numBuckets,
+      final List<List<String>> listBucketCols = new ArrayList<>();
+      final List<CustomBucketFunction> bucketFunctions = new ArrayList<>();
+      final int numBuckets;

Review Comment:
   Because I prefer to use `final` and see a compile error when I mistakenly 
reassign it multiple times or mistakenly miss explicitly assigning a value. 
This is my preference, and I will fix it



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to