[
https://issues.apache.org/jira/browse/CALCITE-4608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17351364#comment-17351364
]
Amrish Lal commented on CALCITE-4608:
-------------------------------------
I agree that the semantics of isInteger() function are not very clear and even
if isInteger() returns true, it does not mean that the value conforms to
java.lang.Integer. It might be best to deprecate this function and use
SqlNumericLiteral.createSqlType() function instead which seems to be doing a
better job of type checking bounds.
However, I do think it's a good idea to properly set scale and precision of any
numerical value and, among other things, that would provide a way to quickly
check whether the numerical value can be written without a decimal point.
SqlNumericLiteral.createSqlType() function also appears to be relying on scale
being set.
The other option seems to be to pull out the underlying BigDecimal value and
then check its scale and precision instead of using methods on
SqlNumericLiteral?
> Fix NullPointerException in SqlNumericLiteral.isInteger()
> ---------------------------------------------------------
>
> Key: CALCITE-4608
> URL: https://issues.apache.org/jira/browse/CALCITE-4608
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.26.0
> Reporter: Amrish Lal
> Assignee: Ruben Q L
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.27.0
>
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> In 1.26, a NullPointerException is thrown in SqlNumericLiteral.isInteger(),
> due to "this.scale" being null. This can be reproduced by compiling SQL
> statement "SELECT * FROM testTable WHERE floatColumn >
> 1.7976931348623157E308".
> A null check was added through CALCITE-4199 to fix the NullPointerException;
> however, the root cause is that scale and precision are not being properly
> set in {{SqlLiteral.createApproxNumeric}} function which is called to handle
> {{APPROX_NUMERIC_LITERAL}} token.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)