You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/11/26 19:38:00 UTC

[jira] [Created] (IMPALA-7891) Analyzer does not detect numeric overflow in CAST

Paul Rogers created IMPALA-7891:
-----------------------------------

             Summary: 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


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: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org