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

Documentation does not specify CAST behavior

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.35.0
    • None
    • core
    • None

    Description

      I could not find documentation on how Calcite implements something like CAST(1.9 AS INT).

      I suspect that there are multiple implementations, some for compile-time and some for run-time. In the absence of a spec it's not clear that they agree. The SQL standard leaves this behavior at the choice of the implementation.

      At least RexExecutorImpl uses BigDecimal.intValue for this expression, which means that the result is 1 rather than 2, as I would have guessed.

      Moreover, there are many tests in SqlOperatorTests which are disabled with "brokenTestsEnabled". Most of these tests look wrong too, claiming that the above cast should fail with an error of out of range, e.g., see testCastWithRoundingToScalar. So reading the test code also does not answer this question.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated: