vvysotskyi commented on a change in pull request #552: [CALCITE-2018] Queries 
failed with AssertionError: rel has lower cost…
URL: https://github.com/apache/calcite/pull/552#discussion_r275722688
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
 ##########
 @@ -311,21 +313,24 @@ void mergeWith(
     assert otherSet.equivalentSet == null;
     LOGGER.trace("Merge set#{} into set#{}", otherSet.id, id);
     otherSet.equivalentSet = this;
+    final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
 
     // remove from table
     boolean existed = planner.allSets.remove(otherSet);
     assert existed : "merging with a dead otherSet";
 
+    final Map<RelSubset, RelNode> changedSubsets = Maps.newIdentityHashMap();
+
     // merge subsets
     for (RelSubset otherSubset : otherSet.subsets) {
       planner.ruleQueue.subsetImportances.remove(otherSubset);
       RelSubset subset =
           getOrCreateSubset(
               otherSubset.getCluster(),
               otherSubset.getTraitSet());
+      // collect RelSubset instances, whose best should be changed
       if (otherSubset.bestCost.isLt(subset.bestCost)) {
-        subset.bestCost = otherSubset.bestCost;
-        subset.best = otherSubset.best;
+        changedSubsets.put(subset, otherSubset.best);
 
 Review comment:
   Good assumption, but when registering new rel nodes into this `RelSet` from 
`otherSubset`, the best cost for `subset` may be changed, and therefore 
`otherSubset.best` should be passed, since it is better according to the check 
above. Also, `otherSubset` is not changed and therefore there is no need to try 
to update its best cost.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to