Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4886

When converting SQL to RelNode, SqlOrderBy is missing in sub-query that contains SqlSetOperator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 1.28.0
    • 1.32.0
    • core
    • None

    Description

      When I run the following test in SqlToRelConverterTest.java:

      @Test void testIntersectWithNulls() {
      final String sql = ""
      + "select deptno from\n"
      + "(select deptno from dept\n"
      + "union all\n"
      + "select deptno from emp order by deptno) as alia";
      final RelNode rel = tester.convertSqlToRel(sql).rel;
      System.out.println(RelOptUtil.toString(rel));
      }
      

      The RelNode is:

      LogicalProject(DEPTNO=[$0])
        LogicalUnion(all=[true])
          LogicalProject(DEPTNO=[$0])
            LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
          LogicalProject(DEPTNO=[$7])
            LogicalTableScan(table=[[CATALOG, SALES, EMP]])
      

      I also tried INTERSECT and EXCEPT, which they all lost ORDER BY operator.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              VAE ZheHu
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: