[ 
https://issues.apache.org/jira/browse/CALCITE-5742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-5742:
------------------------------------
    Labels: pull-request-available  (was: )

> SubstitutionVisitor Causes Infinite Loop when using 
> AggregateOnCalcToAggregateUnifyRule
> ---------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5742
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5742
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: junheleo
>            Priority: Major
>              Labels: pull-request-available
>
> Here is a simple code snippet to reproduce the issue:
> {code:java}
> // Test case in MaterializedViewSubstitutionVisitorTest
> @Test void testAggregateOnProject6() {
>   sql("select count(1) from (select \"empid\", \"deptno\", \"name\", count(*) 
> from \"emps\""
>           + "group by \"empid\", \"deptno\", \"name\" limit 10)  ",
>       "select \"empid\", \"deptno\" from (select \"empid\", \"deptno\", 
> \"name\", count(*) from \"emps\"\n"
>           + "group by \"empid\", \"deptno\", \"name\" limit 10) group by 
> \"empid\", \"deptno\"")
>       .noMat();
> }{code}
> Canonicalized Query Plan:
> {code:java}
> -- Query Plan 
> LogicalAggregate(group=[{0, 1}])
>   LogicalCalc(expr#0..3=[{inputs}], proj#0..1=[{exprs}])
>     LogicalSort(fetch=[10])
>       LogicalAggregate(group=[{0, 1, 2}], EXPR$3=[COUNT()])
>         LogicalCalc(expr#0..4=[{inputs}], proj#0..2=[{exprs}])
>           LogicalTableScan(table=[[hr, emps]]){code}
> Canonicalized Target Plan:
> {code:java}
> -- Target Plan 
> LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
>   LogicalSort(fetch=[10])
>     LogicalAggregate(group=[{0, 1, 2}], EXPR$3=[COUNT()])
>       LogicalCalc(expr#0..4=[{inputs}], proj#0..2=[{exprs}])
>         LogicalTableScan(table=[[hr, emps]]){code}
> The input of Calc Under Aggregate was changed when executing permute in 
> AggregateOnCalcToAggregateUnifyRule, then Visitor can not skip out because 
> the condition "queryDescendant == r.after" is not met.
> Thank you for your attention to this matter
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to