Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.doris.planner;

import com.google.common.base.Predicates;
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.ExprSubstitutionMap;
Expand Down Expand Up @@ -223,6 +224,16 @@ public void unsetLimit() {
limit = -1;
}

protected List<TupleId> getAllScanTupleIds() {
List<TupleId> tupleIds = Lists.newArrayList();
List<ScanNode> scanNodes = Lists.newArrayList();
collectAll(Predicates.instanceOf(ScanNode.class), scanNodes);
for(ScanNode node: scanNodes) {
tupleIds.addAll(node.getTupleIds());
}
return tupleIds;
}

public ArrayList<TupleId> getTupleIds() {
Preconditions.checkState(tupleIds != null);
return tupleIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

/**
Expand Down Expand Up @@ -283,7 +285,8 @@ private PlanNode createQueryPlan(QueryStmt stmt, Analyzer analyzer, long default

if (analyzer.hasEmptyResultSet()) {
// Must clear the scanNodes, otherwise we will get NPE in Coordinator::computeScanRangeAssignment
scanNodes.clear();
Set<TupleId> scanTupleIds = new HashSet<>(root.getAllScanTupleIds());
scanNodes.removeIf(scanNode -> scanTupleIds.contains(scanNode.getTupleIds().get(0)));
PlanNode node = createEmptyNode(stmt, analyzer);
// Ensure result exprs will be substituted by right outputSmap
node.setOutputSmap(root.outputSmap);
Expand Down