zabetak commented on a change in pull request #1686: [CALCITE-3630] Improve
ReduceExpressionsRule
URL: https://github.com/apache/calcite/pull/1686#discussion_r361459282
##########
File path:
core/src/main/java/org/apache/calcite/rel/rules/ReduceExpressionsRule.java
##########
@@ -270,6 +270,8 @@ private void reduceNotNullableFilter(
} else {
call.transformTo(createEmptyRelOrEquivalent(call, filter));
}
+ // New plan is absolutely better than old plan.
+ call.getPlanner().setImportance(filter, 0.0);
Review comment:
Usages of `setImportance` indeed require some care. I think, this change for
example could lead to a `CannotPlanException` that could be avoided before.
Assume that we enter the else branch and we create an empty `LogicalValues`.
Then if the rule set does not contain a `PhysicalValues` we may end-up with a
`CannotPlanException`. Without this change this wouldn't be the case since the
old plan could still be matched by other rules and create a `PhysicalFilter`
etc. I admit this is a contrived example but I wanted to highlight that setting
importance explicitly might be risky.
----------------------------------------------------------------
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