calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jin xing (JIRA)" <>
Subject [jira] [Created] (CALCITE-3226) RelBuilder doesn't keep the alias when scan from an expanded view
Date Fri, 02 Aug 2019 06:37:00 GMT
jin xing created CALCITE-3226:

             Summary: RelBuilder doesn't keep the alias when scan from an expanded view
                 Key: CALCITE-3226
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: jin xing

In current implementation of {{RelBuilder::scan}} ([]),
the alias can be derived and recorded into {{Frame}} only when the {{RelNode}} is a {{TableScan}}
 But when {{RelBuilder::scan}} from an expanded view, the node is not a {{TableScan}} and the
alias is not kept.  Below test failed - we cannot reference a field by alias "MYVIEW".
  @Test public void testExpandViewShouldKeepAlias() throws SQLException {
    try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
      final Frameworks.ConfigBuilder configBuilder =
      final RelOptTable.ViewExpander viewExpander =
          (RelOptTable.ViewExpander) Frameworks.getPlanner(;
      final RelFactories.TableScanFactory tableScanFactory =
      final RelBuilder builder = RelBuilder.create(;
      RelNode node =
                  builder.field(1, "MYVIEW", "EMPNO"),
                  builder.field(1, "MYVIEW", "ENAME"))
      String expected =
          "LogicalProject(EMPNO=[$0], ENAME=[$1])\n"
              + "  LogicalFilter(condition=[=(1, 1)])\n"
                  + "    LogicalTableScan(table=[[scott, EMP]])\n";
      assertThat(node, hasTree(expected));

This message was sent by Atlassian JIRA

View raw message