Skip to content

Commit d99156a

Browse files
BiteTheDDDDtCopilot
andcommitted
[fix](fe) Mark all TopN filter sources as runtime predicates
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: TopN runtime filters record their source node ids on the target scan node thrift, but the coordinator only marked OlapScan-related source SortNodes as runtime-predicate sources before serializing the plan. For non-Olap scans such as external file scans, the source SortNode could keep a non-runtime-predicate sort algorithm for larger limits, so BE received the ids but filtered them out because the runtime predicate source was never detected. This change marks every scan node's TopN filter source SortNode consistently in both coordinator thrift paths. ### Release note Fix TopN runtime filter activation for non-Olap scan targets. ### Check List (For Author) - Test: Unit Test - ./run-fe-ut.sh --run org.apache.doris.qe.runtime.ThriftPlansBuilderTest,org.apache.doris.qe.CoordinatorTest#testTopnFilterDescsSharedAmongInstances - ./build.sh --fe - Behavior changed: Yes. TopN runtime filters on non-Olap scan targets now activate consistently with their serialized source node ids. - Does this need documentation: No Co-authored-by: Copilot <[email protected]>
1 parent d1eef1e commit d99156a

3 files changed

Lines changed: 42 additions & 7 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,6 @@ public FragmentExecParams(PlanFragment fragment) {
32343234

32353235
Map<TNetworkAddress, TPipelineFragmentParams> toThrift(int backendNum) {
32363236
Set<SortNode> topnSortNodes = scanNodes.stream()
3237-
.filter(scanNode -> scanNode instanceof OlapScanNode)
32383237
.flatMap(scanNode -> scanNode.getTopnFilterSortNodes().stream()).collect(Collectors.toSet());
32393238
topnSortNodes.forEach(SortNode::setHasRuntimePredicate);
32403239

‎fe/fe-core/src/main/java/org/apache/doris/qe/runtime/ThriftPlansBuilder.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.doris.planner.DataStreamSink;
4242
import org.apache.doris.planner.ExchangeNode;
4343
import org.apache.doris.planner.MultiCastDataSink;
44-
import org.apache.doris.planner.OlapScanNode;
4544
import org.apache.doris.planner.OlapTableSink;
4645
import org.apache.doris.planner.PlanFragment;
4746
import org.apache.doris.planner.PlanFragmentId;
@@ -190,12 +189,10 @@ public static Map<DistributedPlanWorker, TPipelineFragmentParamsList> plansToThr
190189
return workerToInstances;
191190
}
192191

193-
private static void setRuntimePredicateIfNeed(Collection<ScanNode> scanNodes) {
192+
static void setRuntimePredicateIfNeed(Collection<ScanNode> scanNodes) {
194193
for (ScanNode scanNode : scanNodes) {
195-
if (scanNode instanceof OlapScanNode) {
196-
for (SortNode topnFilterSortNode : scanNode.getTopnFilterSortNodes()) {
197-
topnFilterSortNode.setHasRuntimePredicate();
198-
}
194+
for (SortNode topnFilterSortNode : scanNode.getTopnFilterSortNodes()) {
195+
topnFilterSortNode.setHasRuntimePredicate();
199196
}
200197
}
201198
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.doris.qe.runtime;
19+
20+
import org.apache.doris.planner.ScanNode;
21+
import org.apache.doris.planner.SortNode;
22+
23+
import org.junit.jupiter.api.Test;
24+
import org.mockito.Mockito;
25+
26+
import java.util.Collections;
27+
28+
public class ThriftPlansBuilderTest {
29+
@Test
30+
public void testSetRuntimePredicateForNonOlapScanNode() {
31+
ScanNode scanNode = Mockito.mock(ScanNode.class);
32+
SortNode sortNode = Mockito.mock(SortNode.class);
33+
Mockito.when(scanNode.getTopnFilterSortNodes()).thenReturn(Collections.singletonList(sortNode));
34+
35+
ThriftPlansBuilder.setRuntimePredicateIfNeed(Collections.singletonList(scanNode));
36+
37+
Mockito.verify(sortNode).setHasRuntimePredicate();
38+
}
39+
}

0 commit comments

Comments
 (0)