[
https://issues.apache.org/jira/browse/CALCITE-6734?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ZheHu resolved CALCITE-6734.
----------------------------
Resolution: Fixed
Fixed in
[{{137fed2}}|https://github.com/apache/calcite/commit/137fed23f91ba687f6c4b029e4b654e616191e47],
thanks for the PR [~viggoc] .
Thank you for the review! [~rubenql]
> RelFieldTrimmer should trim Aggregate's input fields which are arguments of
> unused aggregate functions
> ------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-6734
> URL: https://issues.apache.org/jira/browse/CALCITE-6734
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.38.0
> Reporter: Viggo Chen
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.39.0
>
>
> {code:java}
> SELECT DEPTNO,
> SAL
> FROM
> (SELECT DEPTNO,
> SUM(SAL) AS SAL,
> COUNT(ENAME) AS ENAME
> FROM EMP
> WHERE DEPTNO > 100
> GROUP BY DEPTNO)
> {code}
> For above sql, ENAME is unnecessary to read.
> As show in [https://github.com/apache/calcite/pull/4095]
> The expected plan is
> {code:java}
> LogicalAggregate(group=[{2}], SAL=[SUM($1)])
> LogicalFilter(condition=[>($2, 100)])
> LogicalProject(EMPNO=[$0], SAL=[$5], DEPTNO=[$7])
> LogicalTableScan(table=[[scott, EMP]]) {code}
> but what we get now is
> {code:java}
> LogicalAggregate(group=[{3}], SAL=[SUM($2)])
> LogicalFilter(condition=[>($3, 100)])
> LogicalProject(EMPNO=[$0], ENAME=[$1], SAL=[$5], DEPTNO=[$7])
> LogicalTableScan(table=[[scott, EMP]]) {code}
>
> PS: EMPNO is kept because it define the collation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)