[
https://issues.apache.org/jira/browse/CALCITE-6013?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tanner Clary updated CALCITE-6013:
----------------------------------
Summary: Query with GROUP BY fails to prune measure columns during rel
construction (was: Unnecessary measures added as projects during rel
construction)
> Query with GROUP BY fails to prune measure columns during rel construction
> --------------------------------------------------------------------------
>
> Key: CALCITE-6013
> URL: https://issues.apache.org/jira/browse/CALCITE-6013
> Project: Calcite
> Issue Type: Bug
> Reporter: Tanner Clary
> Assignee: Tanner Clary
> Priority: Major
> Labels: pull-request-available
>
> If you have a test like the following (modified from
> {{SqlToRelConverterTest#testMeasureRef}})
> {code:java}
> final String sql = "select deptno as c\n"
> + "from empm\n"
> + "group by deptno";
> fixture()
> .withFactory(c ->
> c.withOperatorTable(t ->
> SqlValidatorTest.operatorTableFor(SqlLibrary.CALCITE)))
> .withCatalogReader(MockCatalogReaderExtended::create)
> .withSql(sql)
> .ok();
> {code}
> The expected results should look something like:
> {code:java}
> LogicalAggregate(group=[{0}])
> LogicalProject(C=[$7])
> LogicalTableScan(table=[[CATALOG, SALES, EMPM]])
> {code}
> Instead it looks like:
> {code:java}
> LogicalAggregate(group=[{0}])
> LogicalProject(C=[$7], COUNT_PLUS_100=[$9], COUNT_TIMES_100=[$10])
> LogicalTableScan(table=[[CATALOG, SALES, EMPM]])
> {code}
> I believe this is due to commit
> [568ce12|https://github.com/apache/calcite/commit/568ce125e6d81fe0815f1317ccaf4d558688d945#diff-5d7c774cd39d94b119eedcf3d361e72406c7864e916736c533bbe8f893ca72bcR3397].
> In essence, the measures should not be added to the projects unless necessary.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)