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

Query with NOT IN operator and literal throws AssertionError: 'Cast for just nullability not allowed'

    Details

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

      Description

      This test

        @Test
        public void testNotInWithLiteral() {
          final String sql = "SELECT *\n"
              + "FROM SALES.NATION\n"
              + "WHERE n_name NOT IN\n"
              + "    (SELECT ''\n"
              + "     FROM SALES.NATION)";
          sql(sql).with(getTesterWithDynamicTable()).ok();
        }
      

      fails with error:

      java.lang.AssertionError: Cast for just nullability not allowed
      
      	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
      	at org.apache.calcite.rel.core.Filter.isValid(Filter.java:116)
      	at org.apache.calcite.test.SqlToRelConverterTest$RelValidityChecker.visit(SqlToRelConverterTest.java:2753)
      	at org.apache.calcite.rel.SingleRel.childrenAccept(SingleRel.java:72)
      	at org.apache.calcite.rel.RelVisitor.visit(RelVisitor.java:44)
      	at org.apache.calcite.test.SqlToRelConverterTest$RelValidityChecker.visit(SqlToRelConverterTest.java:2756)
      	at org.apache.calcite.rel.RelVisitor.go(RelVisitor.java:61)
      	at org.apache.calcite.test.SqlToRelTestBase.assertValid(SqlToRelTestBase.java:129)
      	at org.apache.calcite.test.SqlToRelTestBase$TesterImpl.assertConvertsTo(SqlToRelTestBase.java:693)
      	at org.apache.calcite.test.SqlToRelConverterTest$Sql.convertsTo(SqlToRelConverterTest.java:2790)
      	at org.apache.calcite.test.SqlToRelConverterTest$Sql.ok(SqlToRelConverterTest.java:2786)
      	at org.apache.calcite.test.SqlToRelConverterTest.testNotInWithLiteral(SqlToRelConverterTest.java:1299)
      

      In this line cast which just changes types nullability was made. The ending type is taken form validator and it was made nullable because right operand has a nullable type.

        Attachments

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              vvysotskyi Volodymyr Vysotskyi
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: