Skip to content

Commit

Permalink
Fix MaterializedView select with CTE bug (apache#5165)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangkaisen authored Jan 4, 2021
1 parent 6c098e4 commit bcf1091
Showing 1 changed file with 3 additions and 4 deletions.
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();

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

0 comments on commit bcf1091

Please sign in to comment.