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

SqlToRelConverter throws if ORDER BY contains IN

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.32.0, 1.33.0
    • 1.34.0
    • core

    Description

      At the moment the following query throws exception:

      @Test void testOrderByWithSubQuery() {
          String sql = "SELECT empno\n"
              + "FROM emp\n"
              + "ORDER BY\n"
              + "CASE WHEN empno IN (1,2) THEN 0 ELSE 1 END";
          sql(sql).ok();
        }
      
      while converting CASE WHEN `EMP`.`EMPNO` IN (1, 2) THEN 0 ELSE 1 END
      java.lang.RuntimeException: while converting CASE WHEN `EMP`.`EMPNO` IN (1, 2) THEN 0 ELSE 1 END
      	at org.apache.calcite.sql2rel.ReflectiveConvertletTable.lambda$registerNodeTypeMethod$1(ReflectiveConvertletTable.java:98)
      

      It happens because SqlToRelConverter does not register sub-query inside ORDER BY if query does not have aggregation

      Attachments

        Issue Links

          Activity

            People

              dmsysolyatin Dmitry Sysolyatin
              dmsysolyatin Dmitry Sysolyatin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h