Aggarwal-Raghav commented on code in PR #6512:
URL: https://github.com/apache/hive/pull/6512#discussion_r3558291605
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/physical/Vectorizer.java:
##########
@@ -5190,6 +5244,11 @@ private static VectorPTFInfo
createVectorPTFInfo(Operator<? extends OperatorDesc
int[] keyInputColumnMap =
ArrayUtils.toPrimitive(keyInputColumns.toArray(new Integer[0]));
int[] nonKeyInputColumnMap =
ArrayUtils.toPrimitive(nonKeyInputColumns.toArray(new Integer[0]));
+ if (isPartitionOrderBy && partitionKeyCount > 1) {
+ reorderPartitionColumnsToMatchOutputOrder(outputSignature,
evaluatorCount, outputColumnProjectionMap,
Review Comment:
@deniskuzZ I came up with this. Will check the best of both and will raise
PR.
```
diff --git
i/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java
w/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java
index bd60d215ff..1288703402 100644
---
i/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java
+++
w/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFGroupBatches.java
@@ -64,6 +64,7 @@ public class VectorPTFGroupBatches extends PTFPartition {
private int[] bufferedColumnMap;
private int[] orderColumnMap;
private int[] keyWithoutOrderColumnMap;
+ private int[] partitionColumnMap;
private int spillLimitBufferedBatchCount;
private String spillLocalDirs;
@@ -289,12 +290,13 @@ public VectorPTFGroupBatches(Configuration hconf, int
vectorizedPTFMaxMemoryBuff
public void init(VectorPTFEvaluatorBase[] evaluators, int[]
outputProjectionColumnMap,
int[] bufferedColumnMap, TypeInfo[] bufferedTypeInfos, int[]
orderColumnMap,
- int[] keyWithoutOrderColumnMap, VectorizedRowBatch overflowBatch) {
+ int[] keyWithoutOrderColumnMap, int[] partitionColumnMap,
VectorizedRowBatch overflowBatch) {
this.evaluators = evaluators;
this.outputProjectionColumnMap = outputProjectionColumnMap;
this.bufferedColumnMap = bufferedColumnMap;
this.orderColumnMap = orderColumnMap;
this.keyWithoutOrderColumnMap = keyWithoutOrderColumnMap;
+ this.partitionColumnMap = partitionColumnMap;
this.overflowBatch = overflowBatch;
bufferedBatches = new ArrayList<BufferedVectorizedRowBatch>(0);
@@ -772,8 +774,16 @@ private void copyPartitionColumnToOverflow(Object[]
partitionKey) {
final int keyInputColumnCount = keyWithoutOrderColumnMap.length;
for (int i = 0; i < keyInputColumnCount; i++) {
final int keyColumnNum = keyWithoutOrderColumnMap[i];
+ int partitionKeyIndex = -1;
+ for (int j = 0; j < partitionColumnMap.length; j++) {
+ if (partitionColumnMap[j] == keyColumnNum) {
+ partitionKeyIndex = j;
+ break;
+ }
+ }
+ Preconditions.checkState(partitionKeyIndex != -1, "Could not find
keyColumnNum " + keyColumnNum + " in partitionColumnMap");
Preconditions.checkState(overflowBatch.cols[keyColumnNum] != null);
- setRepeatingColumn(partitionKey[i], overflowBatch, keyColumnNum);
+ setRepeatingColumn(partitionKey[partitionKeyIndex], overflowBatch,
keyColumnNum);
}
}
diff --git
i/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFOperator.java
w/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFOperator.java
index 26987a68f4..feb12617de 100644
---
i/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFOperator.java
+++
w/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFOperator.java
@@ -348,6 +348,7 @@ protected void initializeOp(Configuration hconf) throws
HiveException {
bufferedTypeInfos,
orderColumnMap,
keyWithoutOrderColumnMap,
+ vectorPTFInfo.getPartitionColumnMap(),
overflowBatch);
isFirstPartition = true;
diff --git
i/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/ptf/TestVectorPTFGroupBatches.java
w/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/ptf/TestVectorPTFGroupBatches.java
index 3039585817..c74d407c14 100644
---
i/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/ptf/TestVectorPTFGroupBatches.java
+++
w/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/ptf/TestVectorPTFGroupBatches.java
@@ -588,6 +588,7 @@ private void init(VectorPTFGroupBatches groupBatches)
throws HiveException {
/* bufferedTypeInfos */ new TypeInfo[] { getTypeInfo("int"),
getTypeInfo("string") },
/* orderColumnMap */ new int[] { 1 }, // p_date
/* keyWithoutOrderColumnMap */ new int[] { 0 }, // p_mfgr
+ /* partitionColumnMap */ new int[] { 0 },
getFakeOperator().setupOverflowBatch(3, new String[] { "bigint",
"bigint" },
outputProjectionColumnMap, outputTypeInfos));
}
```
--
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]