rubenada commented on a change in pull request #2398:
URL: https://github.com/apache/calcite/pull/2398#discussion_r613864592
##########
File path: core/src/main/java/org/apache/calcite/tools/RelBuilder.java
##########
@@ -1334,22 +1334,27 @@ public RelBuilder filter(Iterable<CorrelationId>
variablesSet,
*
* <p>The predicates are combined using AND,
* and optimized in a similar way to the {@link #and} method.
- * If the result is TRUE no filter is created. */
+ * If simplification is on and the result is TRUE, no filter is created. */
public RelBuilder filter(Iterable<CorrelationId> variablesSet,
Iterable<? extends RexNode> predicates) {
- final RexNode simplifiedPredicates =
- simplifier.simplifyFilterPredicates(predicates);
- if (simplifiedPredicates == null) {
- return empty();
- }
+ RexNode conjunctionPredicates =
Review comment:
This computation of `conjunctionPredicates =
RexUtil.composeConjunction(simplifier.rexBuilder, predicates);` seems useless
if RelBuilder has `config.simplify()` (which should be most of the cases).
Maybe it could be computed only when required? Proposal:
```
final RexNode conjunctionPredicate;
if (config.simplify()) { //same code in the if block
conjunctionPredicates = simplifier.simplifyFilterPredicates(predicates);
if (conjunctionPredicates == null)
return empty();
if (conjunctionPredicates.isAlwaysTrue())
return this;
}
else {
conjunctionPredicates = RexUtil.composeConjunction(simplifier.rexBuilder,
predicates);
}
...
```
--
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]