You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "shampoo liu (Jira)" <ji...@apache.org> on 2023/03/08 12:20:00 UTC
[jira] [Updated] (CALCITE-5566) agg can't be pushed down correctly
[ https://issues.apache.org/jira/browse/CALCITE-5566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
shampoo liu updated CALCITE-5566:
---------------------------------
Description:
{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
was:
{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}
> 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)