[ 
https://issues.apache.org/jira/browse/CALCITE-3124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16979126#comment-16979126
 ] 

Jin Xing commented on CALCITE-3124:
-----------------------------------

If we look at the above process, we will find that there's no RelSubset cycle. 
The root cause is that FilterProjectTransposeRule and 
ProjectFilterTransposeRule don't have exactly opposite functionality, i.e. 
applying FilterProjectTransposeRule firstly and then 
ProjectFilterTransposeRule, the transformed plan is not exactly the same as 
before.

Applying FilterProjectTransposeRule may increase the complexity of filtering 
condition, but applying ProjectFilterTransposeRule will not reduce the 
complexity.

An intuitive approach to fix in ProjectFilterTransposeRule might be as below:
 # Create an RexShuttle by projects;
 # Express the filtering condition by the shuttle;
 # Push the Project down under the Filter

> Infinite rule matching when AggregateRemoveRule is enabled for SUM0
> -------------------------------------------------------------------
>
>                 Key: CALCITE-3124
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3124
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Haisheng Yuan
>            Assignee: Forward Xu
>            Priority: Major
>
> Make the following changes (uncomment return clause) to AggregateRemoveRule, 
> the test case {{JdbcTest.testHavingNot2}} won't complete due to infinite rule 
> matching.
> {noformat}
> --- a/core/src/main/java/org/apache/calcite/rel/rules/AggregateRemoveRule.java
> +++ b/core/src/main/java/org/apache/calcite/rel/rules/AggregateRemoveRule.java
> @@ -102,7 +102,7 @@ public void onMatch(RelOptRuleCall call) {
>          if (aggregation.getKind() == SqlKind.SUM0) {
>          // Bail out for SUM0 to avoid potential infinite rule matching,
>          // because it may be generated by transforming SUM aggregate
>          // function to SUM0 and COUNT.
> -        return;
> +//        return;
>        }
>        final SqlSplittableAggFunction splitter =
>            Objects.requireNonNull(
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to