Skip to content

Commit cbb41cf

Browse files
committed
HIVE-29322: Avoid TopNKeyOperator When Map-Side LIMIT Pushdown Provides Better Pruning
1 parent be14ad0 commit cbb41cf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ql/src/java/org/apache/hadoop/hive/ql/optimizer/topnkey/TopNKeyProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
6666
ReduceSinkOperator reduceSinkOperator = (ReduceSinkOperator) nd;
6767
ReduceSinkDesc reduceSinkDesc = reduceSinkOperator.getConf();
6868

69-
// Check whether the reduce sink operator contains top n
70-
if (reduceSinkDesc.getTopN() < 0 || !reduceSinkDesc.isOrdering()) {
69+
// HIVE-29322: Skip creating TopNKeyOperator when LIMIT pushdown has already applied (topN >= -1)
70+
// and the query uses a single reducer with no partition columns. In this scenario,
71+
// TopNKey offers no extra pruning benefit and only adds unnecessary processing overhead.
72+
if (reduceSinkDesc.getTopN() >= -1 || !reduceSinkDesc.isOrdering()) {
7173
return null;
7274
}
7375

0 commit comments

Comments
 (0)