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


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

Review Comment:
   yes needed both, same check at the two different places for different 
purpose:
   
   1. [Loop (validatePTFOperator) : 
](https://github.com/apache/hive/pull/6752/changes#diff-21c48f3ed27bf53b36056d8ac880d86515e16c9d01ee127e33cc441d158c9f45R3014)
 : this skips the normal arg validation for the column agnostic function. ( 
this behaviour was already there just refractored via enum set)
   
   2. [window wide scan 
(evaluatorArgsReferencePartitionOnlyExprs)](https://github.com/apache/hive/pull/6752/changes#diff-21c48f3ed27bf53b36056d8ac880d86515e16c9d01ee127e33cc441d158c9f45R2934)
 : here column agnostic check skips partition only expression validation 
against its args.



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java:
##########
@@ -2931,6 +2931,17 @@ private boolean validatePTFOperator(PTFOperator op, 
VectorizationContext vContex
       return false;
     }
 
+    if (hasUnbufferedPartitionColumnInEvaluatorArgs(

Review Comment:
   done 



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