deniskuzZ commented on code in PR #6946:
URL: https://github.com/apache/hive/pull/6946#discussion_r4695716338


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java:
##########
@@ -3013,11 +3013,18 @@ private boolean validatePTFOperator(PTFOperator op, 
VectorizationContext vContex
         throw new RuntimeException("Unexpected window type " + 
windowFrameDef.getWindowType());
       }
 
-      // Row mode also accepts a non-constant ntile argument (read from the 
first row of the partition).
-      if (supportedFunctionType == SupportedFunctionType.NTILE &&
-          !isPositiveIntConstant(singleExprNodeDesc)) {
-        setOperatorIssue(functionName + " only supports a positive integer 
constant number of buckets");
-        return false;
+      // A non-constant ntile argument is read from the first row of each 
partition, as in row mode.
+      if (supportedFunctionType == SupportedFunctionType.NTILE) {

Review Comment:
   Could NTILE come out of `COLUMN_AGNOSTIC_FUNCTIONS`? It now takes an 
argument, so the name no longer fits, and being in the set is why this branch 
repeats the generic lead/lag check below. Out of the set, the generic block 
does the lead/lag and type checks, and this branch shrinks to the constant 
check:
   ```java
   if (supportedFunctionType == SupportedFunctionType.NTILE && 
singleExprNodeDesc instanceof ExprNodeConstantDesc
       && !isPositiveIntConstant(singleExprNodeDesc)) {
     setOperatorIssue(functionName + " only supports a positive integer as a 
constant number of buckets");
     return false;
   }
   ```
   The partition-key case (`ntile(k) over (partition by k ...)`) then needs 
NTILE as an explicit exception in `evaluatorArgsReferencePartitionOnlyExprs`, 
which is what the TODO on `hasUnbufferedPartitionColumnInEvaluatorArgs` asks 
for. The comment on `VectorPTFDesc.COLUMN_AGNOSTIC_FUNCTIONS` can then go back 
to describing functions without an argument.
   
   If NTILE stays in the set, the nesting can still drop a level: 
`containsLeadLag` returns false for a constant, so the `else` isn't needed:
   ```java
   if (supportedFunctionType == SupportedFunctionType.NTILE) {
     if (singleExprNodeDesc instanceof ExprNodeConstantDesc && 
!isPositiveIntConstant(singleExprNodeDesc)) {
       setOperatorIssue(functionName + " only supports a positive integer as a 
constant number of buckets");
       return false;
     }
     if (containsLeadLag(singleExprNodeDesc)) {
       setOperatorIssue("lead and lag function not supported in argument 
expression of aggregation function "
           + functionName);
       return false;
     }
   }
   ```
   



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