[
https://issues.apache.org/jira/browse/FLINK-38832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xuyang Zhong updated FLINK-38832:
---------------------------------
Attachment: image-2025-12-24-10-50-49-543.png
> Projection pushdown of count(*) in planner changes
> ---------------------------------------------------
>
> Key: FLINK-38832
> URL: https://issues.apache.org/jira/browse/FLINK-38832
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 2.2.0
> Reporter: Hongshun Wang
> Priority: Major
> Fix For: 2.2.1
>
> Attachments: image-2025-12-24-10-50-49-543.png
>
>
> Since 2.2.0, explain of this statement changes:
> {code:java}
> select count(*) from log_table;{code}
>
> In 2.1, only first field of source is needed, thus will be pushed down to
> source.
> {code:java}
> FlinkLogicalCalc(select=[EXPR$0])
> +- FlinkLogicalAggregate(group=[{0}], EXPR$0=[COUNT()])
> +- FlinkLogicalTableSourceScan(table=[[testcatalog, defaultdb, log_table,
> project=[id]]], fields=[id])
> HashAggregate(isMerge=[true], select=[Final_COUNT(count1$0) AS EXPR$0])
> +- Exchange(distribution=[single])
> +- LocalHashAggregate(select=[Partial_COUNT(*) AS count1$0])
> +- TableSourceScan(table=[[testcatalog, defaultdb, log_table,
> project=[id]]], fields=[id]) {code}
>
> in 2.2, id is not pushed down to source.
> {code:java}
> LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
> +- LogicalProject(exprs=[[0]])
> +- LogicalTableScan(table=[[testcatalog, defaultdb, test_log_table]])
> HashAggregate(isMerge=[true], select=[Final_COUNT(count1$0) AS EXPR$0])
> +- Exchange(distribution=[single])
> +- LocalHashAggregate(select=[Partial_COUNT(*) AS count1$0])
> +- TableSourceScan(table=[[testcatalog, defaultdb, log_table]],
> fields=[id, address, name]) {code}
> FlinkLogicalAggregate is changed to LogicalProject.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)