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

Benchao Li commented on CALCITE-5566:
-------------------------------------

[~shpodg] I guess the reason is that the top agg has only one row, it's cost is 
very small so that the JdbcAggregate does not win. This is similar with 
CALCITE-5284.

> agg can't be pushed down correctly
> ----------------------------------
>
>                 Key: CALCITE-5566
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5566
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.33.0
>            Reporter: shampoo liu
>            Priority: Major
>
> {code:sql}
> select count(*) from (select max("position_title") "position_title" from 
> "foodmart"."employee" where "gender" like '%a%' group by "birth_date", 
> "gender") where "position_title" like '%z%'
> {code}
> The plan generated from sql above is as this :
> {code:java}
> PLAN=EnumerableAggregate(group=[{}], EXPR$0=[COUNT()])
>   JdbcToEnumerableConverter
>     JdbcFilter(condition=[LIKE($2, '%z%')])
>       JdbcAggregate(group=[{8, 15}], position_title=[MAX($5)])
>         JdbcFilter(condition=[LIKE($15, '%a%')])
>           JdbcTableScan(table=[[foodmart, employee]])
> {code}
> Expected:
> {code:java}
> PLAN=JdbcToEnumerableConverter
>   JdbcAggregate(group=[{}], EXPR$0=[COUNT()])
>     JdbcFilter(condition=[LIKE($2, '%z%')])
>       JdbcAggregate(group=[{8, 15}], position_title=[MAX($5)])
>         JdbcFilter(condition=[LIKE($15, '%a%')])
>           JdbcTableScan(table=[[foodmart, employee]])
> {code}
> test case: 
> https://github.com/shpodg/calcite/commit/7c7aa35ca9864243e39b8d0559f820c342860754



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

Reply via email to