Mihai Budiu created CALCITE-6073:
------------------------------------

             Summary: Documentation does not specify CAST behavior
                 Key: CALCITE-6073
                 URL: https://issues.apache.org/jira/browse/CALCITE-6073
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.35.0
            Reporter: Mihai Budiu


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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to