[ 
https://issues.apache.org/jira/browse/CALCITE-5990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17774692#comment-17774692
 ] 

Mihai Budiu commented on CALCITE-5990:
--------------------------------------

There is a much more troubling problem, which is that the regression introduced 
was not caught by any test.
This implies that we are missing lots of tests for corner cases of cast 
operators.
sql2rel can only potentially find problems for constant expressions, so runtime 
checks are needed.

> Explicit cast to numeric type doesn't check overflow
> ----------------------------------------------------
>
>                 Key: CALCITE-5990
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5990
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Runkang He
>            Assignee: Runkang He
>            Priority: Blocker
>             Fix For: 1.36.0
>
>
> Explicit cast to numeric type doesn't check overflow, and this issue can be 
> reproduced by sqlline:
> {code:sql}
> select cast(empno as tinyint), cast(130 as tinyint) from emps where 
> name='Alice'; -- empno is 130
> {code}
> The empno is INT type. The result is wrong:
> {code:sql}
> -126, -126{code}
> I think it should throw exception when overflow, instead of returning wrong 
> result to user.
> At last, this issue was found when to turn on runtime check for 
> CalciteSqlOperatorTest in CALCITE-5921.



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

Reply via email to