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

Type mismatch assertion error when converting NOT IN subquery

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.20.0
    • Component/s: core
    • Labels:

      Description

      Repro:
      Add the following test to SqlToRelConverterTest.java.

      @Test public void testSubQueryNotIN() {
          final String sql = "select deptno\n"
              + "from EMP e\n"
              + "where deptno not in (select deptno\n"
              + "from EMP where empno=e.empno)";
          sql(sql).ok();
        }
      

      Error:

      java.lang.AssertionError: type mismatch:
      ref:
      INTEGER NOT NULL
      input:
      INTEGER
      
      	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
      	at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1832)
      	at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:125)
      	at org.apache.calcite.rex.RexChecker.visitInputRef(RexChecker.java:57)
      	at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
      	at org.apache.calcite.rex.RexChecker.visitCall(RexChecker.java:140)
      	at org.apache.calcite.rex.RexChecker.visitCall(RexChecker.java:57)
      	at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)
      	at org.apache.calcite.rel.core.Filter.isValid(Filter.java:120)
      	at org.apache.calcite.rel.logical.LogicalFilter.<init>(LogicalFilter.java:70)
      	at org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:114)
      	at org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:101)
      	at org.apache.calcite.rel.core.RelFactories$FilterFactoryImpl.createFilter(RelFactories.java:300)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.createJoin(SqlToRelConverter.java:2433)
      

      If we change not in subquery to in subquery, it can run without error.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hyuan Haisheng Yuan
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: