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

EnumUtils.convert does not implement the correct SQL cast semantics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • 1.36.0
    • 1.38.0
    • core

    Description

      The code generated by EnumUtil for casts uses the Java semantics, where casts just truncate values. The SQL semantics requires a runtime exception if the value does not fit in the target datatype.

      Some of the bugs in this code generator are masked by the BlockBuilder optimizer which attempts to optimize the generated code using the SQL semantics... But if the code is not optimized and is executed in Java it generates wrong results for most conversions that overflow.

      One additional wrinkle is that it is not entirely clear whether the bug is in EnumUtils or in the code that invokes EnumUtils. It is not specified which of the two semantics for casts EnumUtils are supposed to implement: Java or SQL?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mbudiu Mihai Budiu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: