xndai commented on a change in pull request #1992:
URL: https://github.com/apache/calcite/pull/1992#discussion_r434232172
##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
##########
@@ -490,4 +500,50 @@ void mergeWith(
planner.fireRules(subset);
}
}
+
+ private void checkAndUpdateOriginalRel(RelNode newRel) {
+ if (newRel instanceof LogicalNode && this.originalRel instanceof
LogicalNode
+ && ((LogicalNode) newRel).getStatsEstimateConfidence().compareTo(
+ ((LogicalNode) this.originalRel).getStatsEstimateConfidence()) >
0) {
+ this.originalRel = newRel;
+
+ // Invalidate parent sets original rel meta cache since child set
properties might
+ // have been changed.
+ HashSet<RelSet> newParentSets = getParentSets();
+ HashSet<RelSet> allParentSets = new HashSet<>();
+ while (!newParentSets.isEmpty()) {
+ allParentSets.addAll(newParentSets);
+ HashSet<RelSet> validParents = new HashSet<>();
+ for (RelSet set : newParentSets) {
+ HashSet<RelSet> parents = set.getParentSets();
+ for (RelSet s : parents) {
+ // To handle cycle references between sets
+ if (!allParentSets.contains(s)) {
+ validParents.add(s);
+ }
+ }
+ }
+ newParentSets = validParents;
+ }
+ for (RelSet set : allParentSets) {
+ final RelMetadataQuery mq =
set.originalRel.getCluster().getMetadataQuery();
+ mq.clearCache(set.originalRel);
+ }
+ }
+ }
+
+ private HashSet<RelSet> getParentSets() {
+ HashSet<RelSet> results = new HashSet<>();
+ VolcanoPlanner planner = (VolcanoPlanner)
this.originalRel.getCluster().getPlanner();
+ assert planner != null;
+
+ for (RelNode rel : getParentRels()) {
+ RelSet set = planner.getSet(rel);
Review comment:
fixed
##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
##########
@@ -293,7 +293,7 @@ public double estimateRowCount(RelMetadataQuery mq) {
return list;
}
- RelSet getSet() {
+ public RelSet getSet() {
Review comment:
fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]