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


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/metainfo/annotation/OpTraitsRulesProcFactory.java:
##########
@@ -367,34 +430,48 @@ public List<List<String>> getConvertedColNames(
     public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
         Object... nodeOutputs) throws SemanticException {
       SelectOperator selOp = (SelectOperator) nd;
-      List<List<String>> parentBucketColNames =
-          selOp.getParentOperators().get(0).getOpTraits().getBucketColNames();
+      OpTraits parentOpTraits = 
selOp.getParentOperators().get(0).getOpTraits();
+      List<List<String>> parentBucketColNames = 
parentOpTraits.getBucketColNames();
 
       List<List<String>> listBucketCols = null;
       List<List<String>> listSortCols = null;
       if (selOp.getColumnExprMap() != null) {
         if (parentBucketColNames != null) {
           listBucketCols = getConvertedColNames(parentBucketColNames, selOp, 
false);
         }
-        List<List<String>> parentSortColNames =
-            selOp.getParentOperators().get(0).getOpTraits().getSortCols();
+        List<List<String>> parentSortColNames = parentOpTraits.getSortCols();
         if (parentSortColNames != null) {
           listSortCols = getConvertedColNames(parentSortColNames, selOp, true);
         }
       }
 
-      int numBuckets = -1;
-      int numReduceSinks = 0;
-      OpTraits parentOpTraits = 
selOp.getParentOperators().get(0).getOpTraits();
-      if (parentOpTraits != null) {
-        // if bucket columns are empty, then numbuckets must be set to -1.
-        if (listBucketCols != null &&
-            !(listBucketCols.isEmpty() || listBucketCols.get(0).isEmpty())) {
-          numBuckets = parentOpTraits.getNumBuckets();
+      final List<CustomBucketFunction> bucketFunctions;
+      if (listBucketCols == null) {
+        bucketFunctions = null;
+      } else {
+        Preconditions.checkState(parentBucketColNames.size() == 
listBucketCols.size());
+        bucketFunctions = new ArrayList<>();
+        for (int i = 0; i < listBucketCols.size(); i++) {
+          if (listBucketCols.get(i).isEmpty()) {
+            bucketFunctions.add(null);
+          } else {
+            Preconditions.checkState(listBucketCols.get(i).size() == 
parentBucketColNames.get(i).size());
+            
bucketFunctions.add(parentOpTraits.getCustomBucketFunctions().get(i));
+          }
         }
-        numReduceSinks = parentOpTraits.getNumReduceSinks();
       }
-      OpTraits opTraits = new OpTraits(listBucketCols, numBuckets, 
listSortCols,
+
+      final int numBuckets;
+      // if bucket columns are empty, then numbuckets must be set to -1.
+      if (listBucketCols == null || listBucketCols.isEmpty() || 
listBucketCols.get(0).isEmpty()) {

Review Comment:
   Done
   
https://github.com/apache/hive/pull/5409/commits/c6aa9d2d0a81ff2e8834e1350a18405e593fe212



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