Skip to content

Commit 43f2cb7

Browse files
committed
fix
1 parent f661d63 commit 43f2cb7

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

ql/src/java/org/apache/hadoop/hive/ql/optimizer/SortedDynPartitionOptimizer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
215215
if (customSortExprs.isEmpty() && !shouldDo(partitionPositions, customPartitionExprs, fsParent, allRSCols)) {
216216
return null;
217217
}
218+
219+
// Mark that sorting will be applied with custom partition expressions, so the writer layer
220+
// (e.g. Iceberg) knows the input is ordered and can use a clustered writer.
221+
if (!customPartitionExprs.isEmpty()) {
222+
dpCtx.setHasCustomPartitionOrSortExpression(true);
223+
}
218224
// if RS is inserted by enforce bucketing or sorting, we need to remove it
219225
// since ReduceSinkDeDuplication will not merge them to single RS.
220226
// RS inserted by enforce bucketing/sorting will have bucketing column in

ql/src/java/org/apache/hadoop/hive/ql/plan/DynamicPartitionCtx.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ public List<Function<List<ExprNodeDesc>, ExprNodeDesc>> getCustomPartitionExpres
252252
public void addCustomPartitionExpressions(
253253
List<Function<List<ExprNodeDesc>, ExprNodeDesc>> customPartitionExpressions) {
254254
if (!org.apache.commons.collections.CollectionUtils.isEmpty(customPartitionExpressions)) {
255-
this.hasCustomPartitionOrSortExpr = true;
256255
this.customPartitionExpressions.addAll(customPartitionExpressions);
257256
}
258257
}
@@ -290,4 +289,8 @@ public void setCustomSortNullOrder(List<Integer> customSortNullOrder) {
290289
public boolean hasCustomPartitionOrSortExpression() {
291290
return hasCustomPartitionOrSortExpr;
292291
}
292+
293+
public void setHasCustomPartitionOrSortExpression(boolean hasCustomPartitionOrSortExpr) {
294+
this.hasCustomPartitionOrSortExpr = hasCustomPartitionOrSortExpr;
295+
}
293296
}

0 commit comments

Comments
 (0)