Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

/**
* Constructs a non-executable single-node plan from an analyzed parse tree.
Expand All @@ -86,7 +85,7 @@ public class SingleNodePlanner {

private final PlannerContext ctx_;
private final ArrayList<ScanNode> scanNodes = Lists.newArrayList();
private Map<UUID, List<ScanNode>> selectStmtToScanNodes = Maps.newHashMap();
private Map<Analyzer, List<ScanNode>> selectStmtToScanNodes = Maps.newHashMap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Analyzer of CTE same as outer query?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.
For SQL

select id, t1 from(
select id, a as t1 from t
union all
select id, aaa as t1 from t
) k2;

The analyzer instances for select id, a as t1 from t and select id, aaa as t1 from t are different.
Such as, The analyzer instances for select id, a as t1 from t is 6177, which ancestors are[6219,6220,6221],
The analyzer instances for select id, aaa as t1 from t is 6225, which ancestors are[6247,6220,6221].


public SingleNodePlanner(PlannerContext ctx) {
ctx_ = ctx;
Expand Down Expand Up @@ -778,7 +777,7 @@ public boolean selectMaterializedView(QueryStmt queryStmt, Analyzer analyzer)
((InlineViewRef) tableRef).getAnalyzer());
}
}
List<ScanNode> scanNodeList = selectStmtToScanNodes.get(selectStmt.getId());
List<ScanNode> scanNodeList = selectStmtToScanNodes.get(selectStmt.getAnalyzer());
if (scanNodeList == null) {
return selectFailed;
}
Expand Down Expand Up @@ -1455,7 +1454,7 @@ private PlanNode createScanNode(Analyzer analyzer, TableRef tblRef, SelectStmt s
analyzer.materializeSlots(scanNode.getConjuncts());

scanNodes.add(scanNode);
List<ScanNode> scanNodeList = selectStmtToScanNodes.computeIfAbsent(selectStmt.getId(), k -> Lists.newArrayList());
List<ScanNode> scanNodeList = selectStmtToScanNodes.computeIfAbsent(selectStmt.getAnalyzer(), k -> Lists.newArrayList());
scanNodeList.add(scanNode);
return scanNode;
}
Expand Down