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

SqlToRelConverter: SELECT 1 IS [NOT] DISTINCT FROM NULL fails with AssertionError

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      Problem can be reproduced with the following tests (in core\src\test\resources\sql\misc.iq):

      # [CALCITE-4258]
      SELECT 1 IS DISTINCT FROM NULL;
      +--------+
      | EXPR$0 |
      +--------+
      | true   |
      +--------+
      (1 row)
      
      !ok
      
      # [CALCITE-4258]
      SELECT 1 IS NOT DISTINCT FROM NULL;
      +--------+
      | EXPR$0 |
      +--------+
      | false  |
      +--------+
      (1 row)
      
      !ok
      

      These tests fail with:

      > java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
      > validated type:
      > RecordType(BOOLEAN NOT NULL EXPR$0) NOT NULL
      > converted type:
      > RecordType(BOOLEAN EXPR$0) NOT NULL
      > rel:
      > LogicalProject(EXPR$0=[null:BOOLEAN])
      >   LogicalValues(tuples=[[{ 0 }]])
      44a47,109
      > 	at org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:466)
      > 	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:581)
      > 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:242)
      > 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:208)
      ...
      

      These queries used to work fine until recently, so this regression must have occurred not so long ago.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            2 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 - 20m
                20m

                Slack

                  Issue deployment