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

RelToSqlConverter handling "NOT IN" incorrectly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Bug
    • None
    • 1.21.0
    • core
    • 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

            atharv.raj Atharv Rajput
            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