[ https://issues.apache.org/jira/browse/CALCITE-6013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17867911#comment-17867911 ]
Julian Hyde commented on CALCITE-6013: -------------------------------------- I revised the fix in [5b996bd|https://github.com/apache/calcite/commit/5b996bd595cbe775f7534f14546db66241f32eda]. > RelBuilder should simplify plan by pruning unused measures > ---------------------------------------------------------- > > 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 > Fix For: 1.36.0 > > > 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)