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

RelToSqlConverter handling "NOT IN" incorrectly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: 1.21.0
    • Component/s: core
    • Labels:
      None

      Description

      When RelNode is having `NOT IN` operator, it's being converted incorrectly by RelToSqlConverter. For example

      @Test public void testNotInOperator() {
        final RelBuilder builder = relBuilder().scan("EMP");
        final RexNode condition =
          builder.call(SqlStdOperatorTable.NOT_IN, builder.field("DEPTNO"),
            builder.literal(20), builder.literal(30));
        final RelNode root = relBuilder().scan("EMP").filter(condition).build();
        final String sql = toSql(root);
        final String expectedSql = "SELECT *\n"
          + "FROM \"scott\".\"EMP\"\n"
          + "WHERE \"DEPTNO\" NOT IN (20, 30)";
        assertThat(sql, isLinux(expectedSql));
      }
      

      Above test fails with error:

      Expected: is "SELECT *\nFROM \"scott\".\"EMP\"\nWHERE \"DEPTNO\" NOT IN (20, 30)"
      but: was "SELECT *\nFROM \"scott\".\"EMP\"\nWHERE \"DEPTNO\" NOT IN 20 NOT IN 30"
      

       

        Attachments

          Activity

            People

            • Assignee:
              atharv.raj Atharv Rajput
              Reporter:
              atharv.raj Atharv Rajput
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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