[ https://issues.apache.org/jira/browse/CALCITE-4302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224950#comment-17224950 ]
Vladimir Sitnikov commented on CALCITE-4302: -------------------------------------------- [~botong], [~danny0405], this change introduced a case for NPE in {{propagateCostImprovements}} See https://github.com/apache/calcite/blob/b20e0bf6ca9b605fa4a6203bd06454abd6a98ce2/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java#L955-L957 {code:java} for (RelNode parent : subset.getParents()) { mq.clearCache(parent); RelOptCost newCost = getCost(parent, mq); // <-- this might return null RelOptCost existingCost = propagateRels.get(parent); if (existingCost == null || newCost.isLt(existingCost)) { // newCost.isLt would fail with NPE propagateRels.put(parent, newCost); {code} Would you please adjust the code to properly handle {{null}} from {{getCost}}? > Improve cost propagation in volcano to avoid re-propagation > ----------------------------------------------------------- > > Key: CALCITE-4302 > URL: https://issues.apache.org/jira/browse/CALCITE-4302 > Project: Calcite > Issue Type: Improvement > Reporter: Botong Huang > Assignee: Danny Chen > Priority: Major > Labels: pull-request-available > Fix For: 1.27.0 > > Time Spent: 5h 50m > Remaining Estimate: 0h > > CALCITE-3330 changed the cost propagation in volcano from DFS to BFS. > However, there is still room for improvement. A subset can be updated more > than once in a cost propagation process. For instance, A -> D, A -> B -> C -> > D. When subset A has an update, using BFS subset D (and thus all subsets > above/after D) can be updated twice, first via A -> D and then C -> D. We can > further improve the BFS by always popping the relNode with the smallest cost > from the queue, similar to the Dijkstra algorithm. So that whenever a relNode > is popped from the queue, its current best cannot be further deceased any > more. As a result, all subsets will only be propagated at most once. -- This message was sent by Atlassian Jira (v8.3.4#803005)