You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/09/27 03:30:00 UTC

[jira] [Updated] (CALCITE-4803) RelNode lost alias after remove Project operator

     [ https://issues.apache.org/jira/browse/CALCITE-4803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated CALCITE-4803:
------------------------------------
    Labels: pull-request-available  (was: )

> RelNode lost alias after remove Project operator
> ------------------------------------------------
>
>                 Key: CALCITE-4803
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4803
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: xzh_dz
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
>  In my project, I often use `RelOptRule` to optimize relational algebra. In the process of materialized view optimization, after removing the `Project operator`, I found that RelNode lost its alias and their relational algebra is not equivalent.Examples can be reproduced as follows.
>  
> {code:java}
> // code placeholder
> org.apache.calcite.test.SqlToRelConverterTest
> @Test void testLoseAlias() {
>   final String sql = "select ename as e, deptno as d, count(distinct empno) from emp group by ename, deptno";
>   final RelNode rel = tester.convertSqlToRel(sql).rel;
>   // LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT(DISTINCT $2)])
>   //  LogicalProject(E=[$1], D=[$7], EMPNO=[$0])
>   //    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>   System.out.println(RelOptUtil.toString(rel));
>   final HepProgramBuilder programBuilder = HepProgram.builder();
>   programBuilder.addRuleInstance(CoreRules.AGGREGATE_PROJECT_MERGE);
>   final HepPlanner planner = new HepPlanner(programBuilder.build());
>   planner.setRoot(rel);
>   final RelNode relOpt = planner.findBestExp();
>   //LogicalAggregate(group=[{1, 7}], EXPR$2=[COUNT(DISTINCT $0)])
>   //  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
>   System.out.println(RelOptUtil.toString(relOpt));
>   // [ENAME, DEPTNO, EXPR$2]
>   System.out.println(relOpt.getRowType().getFieldNames());
> }
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)