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

Assertion error on PERCENT_REMAINDER operator with DECIMAL type

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.33.0
    • None

    Description

      Queries like:

      SELECT 1.0 % 2 

      Fail on planning with:

      java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
      validated type:
      RecordType(INTEGER NOT NULL EXPR$0) NOT NULL
      converted type:
      RecordType(DECIMAL(2, 1) NOT NULL EXPR$0) NOT NULL
           at org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:494)
           at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:609)
           at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:257)

      It happens because PERCENT_REMAINDER operator replaced with MOD operator by StandardConvertletTable and these two operators have different return-type inference settings. So, different types are inferenced at SQL validation phase and SqlToRel converter phase.

       

      Attachments

        Issue Links

        Activity

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

          People

            alex_pl Aleksey Plekhanov
            alex_pl Aleksey Plekhanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 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