[
https://issues.apache.org/jira/browse/IMPALA-7891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16699488#comment-16699488
]
Tim Armstrong commented on IMPALA-7891:
---------------------------------------
We want to fix the behaviour in the backend at some point but it would be a
breaking change: IMPALA-6072
> Analyzer does not detect numeric overflow in CAST
> -------------------------------------------------
>
> Key: IMPALA-7891
> URL: https://issues.apache.org/jira/browse/IMPALA-7891
> Project: IMPALA
> Issue Type: Bug
> Components: Frontend
> Affects Versions: Impala 3.0
> Reporter: Paul Rogers
> Assignee: Paul Rogers
> Priority: Minor
>
> Consider the following SQL:
> {code:sql}
> SELECT CAST(257 AS TINYINT) AS c FROM functional.alltypestiny
> {code}
> Run this in the shell:
> {noformat}
> +----------------------+
> | cast(257 as tinyint) |
> +----------------------+
> | 1 |
> +----------------------+
> {noformat}
> The SQL-2016 standard, section 4.4 states:
> bq. If an assignment of some number would result in a loss of its most
> significant digit, an exception condition is raised.
> Expected an error rather than wrong result.
> This is not as simple as it appears. The BE is written in C which does not
> detect integer overflow. So, one could argue that the behavior is correct:
> Impala makes no guarantees about integer overflow.
> On the other hand, the math above is actually done in the planner; the
> serialized plan contains an incorrect value. One could argue that the planner
> should be more strict than the runtime, so that this is an error.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]