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/11/26 17:04:00 UTC
[jira] [Created] (IMPALA-7887) NumericLiteral fails to detect
numeric overflow
Paul Rogers created IMPALA-7887:
-----------------------------------
Summary: 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
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.
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)