vlsi commented on a change in pull request #1610: [CALCITE-3525] RexSimplify:
eliminate redundant rex calls in OR
URL: https://github.com/apache/calcite/pull/1610#discussion_r353667049
##########
File path:
core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java
##########
@@ -181,6 +183,14 @@ public void onMatch(RelOptRuleCall call) {
.project(project.getProjects(),
project.getRowType().getFieldNames())
.build();
+ // if new filter is always false and none of it's inputs use
+ // correlation variables - simplify new project to empty values
+ if (newCondition.isAlwaysFalse() && newFilterRel.getInputs().stream()
+ .map(RelOptUtil::getVariablesUsed)
+ .allMatch(Collection::isEmpty)) {
+ newProjRel = relBuilder.push(newProjRel).empty().build();
Review comment:
> like MongoDB, because such filter can't be implemented properly.
That is exactly the "cost of support" for an adapter. That is why I am not
very keen on merging new adapters (e.g.
https://github.com/apache/calcite/pull/1591 )
There are the following approaches:
a) Implement a consistent way to ensure `where false` is never produced. I
guess that rule does not belong to FilterProjectTransposeRule. `where false`
could appear in many places. And there might be a generic rule that replaces
`where false` with an empty relation, so "adapters that do not support `where
false` could use the rule". I guess such a rule should already exist because it
sounds like a common optimization
b) Implement `where filter` logic for `mongodb`. I do recognize your fix has
nothing to do with `mongo`, but that is exactly the price we pay for having
lots of adapters
c) De-support `mongodb` adapter. In other words, drop the code from Git
----------------------------------------------------------------
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