You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/12/29 00:02:00 UTC
[jira] [Resolved] (IMPALA-7887) NumericLiteral fails to detect
numeric overflow
[ https://issues.apache.org/jira/browse/IMPALA-7887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Rogers resolved IMPALA-7887.
---------------------------------
Resolution: Fixed
> NumericLiteral fails to detect numeric overflow
> -----------------------------------------------
>
> Key: IMPALA-7887
> URL: https://issues.apache.org/jira/browse/IMPALA-7887
> Project: IMPALA
> Issue Type: Bug
> Components: Frontend
> Affects Versions: Impala 3.0
> Reporter: Paul Rogers
> Assignee: Paul Rogers
> Priority: Minor
>
> The {{NumericLiteral}} constructor takes a value and a type. The code does not check that the value is within range of the type, allowing nonsensical values:
> {code:java}
> NumericLiteral n = new NumericLiteral(new BigDecimal("123.45"),
> ScalarType.createDecimalType(3, 1));
> System.out.println(n.getValue().toString());
> n = new NumericLiteral(new BigDecimal(Integer.MAX_VALUE),
> Type.TINYINT);
> System.out.println(n.getValue().toString());
> {code}
> Prints:
> {noformat}
> 123.45
> 2147483647
> {noformat}
> The value 123.45 is not valid for DECIMAL(3,1), nor is 2^31 valid for TINYINT.
> According to the SQL-2016 standard, section 4.4:
> bq. If an assignment of some number would result in a loss of its most significant digit, an exception condition is raised.
> The purpose of the constructor appears to be for "friendly" use where the caller promises not to create incorrect literals. Better would be to enforce this rule.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)