ggangadharan commented on code in PR #6861:
URL: https://github.com/apache/hive/pull/6861#discussion_r4260194734


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFOperator.java:
##########
@@ -474,13 +475,31 @@ private void initBufferedColumns() {
       bufferedTypeInfos[bufferedMapIndex] = 
outputTypeInfos[streamingEvaluatorNum];
     }
 
-    for (int i = 0; i < scratchColumnPositions.length; i++) {
+    for (int i = 0; i < bufferedScratchIndices.length; i++) {
+      final int scratchIndex = bufferedScratchIndices[i];
       final int bufferedMapIndex = orderColumnCount + nonKeyInputColumnCount + 
streamingEvaluatorCount + i;
-      bufferedColumnMap[bufferedMapIndex] = scratchColumnPositions[i];
-      bufferedTypeInfos[bufferedMapIndex] = 
TypeInfoUtils.getTypeInfoFromTypeString(vOutContext.getScratchColumnTypeNames()[i]);
+      bufferedColumnMap[bufferedMapIndex] = 
scratchColumnPositions[scratchIndex];
+      bufferedTypeInfos[bufferedMapIndex] =
+          
TypeInfoUtils.getTypeInfoFromTypeString(vOutContext.getScratchColumnTypeNames()[scratchIndex]);
     }
   }
 
+  /**
+   * Returns the indices (into scratchColumnPositions) of the scratch columns 
written by evaluator
+   * input expressions. Those are evaluated before a batch is buffered, so 
their results must be
+   * buffered too. The other scratch columns belong to child operators, which 
recompute them after
+   * the batch is forwarded; buffering them is wasted work and fails for 
complex types.
+   */
+  private int[] getEvaluatorInputScratchIndices() {
+    final int[] inputExprColumns = Arrays.stream(evaluators)
+        .filter(evaluator -> evaluator.inputVecExpr != null)
+        .mapToInt(evaluator -> evaluator.inputVecExpr.getOutputColumnNum())
+        .toArray();
+    return IntStream.range(0, scratchColumnPositions.length)

Review Comment:
   Done. Collected the evaluator input columns into a Set (only membership is 
needed, no values) and filter the scratch indices with contains.
   
   



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