ramitg254 commented on code in PR #6752:
URL: https://github.com/apache/hive/pull/6752#discussion_r4003435270


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java:
##########
@@ -5039,6 +5047,88 @@ private static ExprNodeDesc[] 
getOrderExprNodeDescs(List<OrderExpressionDef> ord
     return exprNodeDescs;
   }
 
+  // TODO: An evaluator that wants to handle an unbuffered partition-only 
column in its calculation could
+  // opt in to vectorization here.
+  private static boolean hasUnbufferedPartitionColumnInEvaluatorArgs(
+      boolean isPartitionOrderBy,
+      ExprNodeDesc[] partitionExprNodeDescs,
+      ExprNodeDesc[] orderExprNodeDescs,
+      String[] evaluatorFunctionNames,
+      List<ExprNodeDesc>[] evaluatorInputExprNodeDescLists) {
+
+    // PARTITION BY matches ORDER BY, so partition cols are buffered as order 
cols.
+    if (!isPartitionOrderBy) {
+      return false;
+    }
+
+    List<ExprNodeDesc> partitionOnlyExprs =
+        getPartitionOnlyExprs(partitionExprNodeDescs, orderExprNodeDescs);
+    if (partitionOnlyExprs.isEmpty()) {
+      return false;
+    }
+
+    return evaluatorArgsReferencePartitionOnlyExprs(
+        evaluatorFunctionNames, evaluatorInputExprNodeDescLists, 
partitionOnlyExprs);
+  }
+
+  private static boolean evaluatorArgsReferencePartitionOnlyExprs(
+      String[] evaluatorFunctionNames,
+      List<ExprNodeDesc>[] evaluatorInputExprNodeDescLists,
+      List<ExprNodeDesc> partitionOnlyExprs) {
+    for (int i = 0; i < evaluatorFunctionNames.length; i++) {
+      SupportedFunctionType supportedFunctionType =
+          
VectorPTFDesc.supportedFunctionsMap.get(evaluatorFunctionNames[i].toLowerCase());
+      List<ExprNodeDesc> exprNodeDescList = evaluatorInputExprNodeDescLists[i];
+      if (supportedFunctionType == null ||
+          
VectorPTFDesc.COLUMN_AGNOSTIC_FUNCTIONS.contains(supportedFunctionType) ||
+          exprNodeDescList == null) {
+        continue;
+      }
+
+      // Check whether a evaluator argument references a partition-only column.
+      for (ExprNodeDesc exprNodeDesc : exprNodeDescList) {
+        if (hasPartitionOnlyColumnArg(exprNodeDesc, partitionOnlyExprs)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  private static boolean hasPartitionOnlyColumnArg(
+      ExprNodeDesc expr, List<ExprNodeDesc> partitionOnlyExprs) {
+    if (!(expr instanceof ExprNodeColumnDesc)) {
+      return false;
+    }
+    for (ExprNodeDesc partitionOnlyExpr : partitionOnlyExprs) {
+      if (expr.isSame(partitionOnlyExpr)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private static List<ExprNodeDesc> getPartitionOnlyExprs(

Review Comment:
   didn't find any similar api as that 



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