[ 
https://issues.apache.org/jira/browse/CALCITE-4608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17351412#comment-17351412
 ] 

Julian Hyde commented on CALCITE-4608:
--------------------------------------

I've spent some time reading the code, and I now agree that a numeric literal 
should have precision and scale. While there are floating-point *types*, which 
have no fixed scale, there are no floating-point *literals*.

If you write "{{100}}" and "{{1E2}}" you will get literals with the same value, 
but the latter will have {{SqlNumericLiteral.isExact = false}}. I don't see why 
the {{isExact}} flag needs to exist. The only code that uses {{isExact}} is in 
{{SqlWindow}}, and will throw if you write "{{ROWS 1E2 FOLLOWING}}" but not 
"{{ROWS 100 FOLLOWING}}". I am not sure that this difference is required by 
standard SQL.

How about we eliminate the {{isExact}} field in {{SqlNumericLiteral}}, convert 
the {{prec}} and {{scale}} fields to {{public final int}}, use these fields 
rather than their accessor methods (which are of type {{Integer}} and cannot be 
changed) and see what breaks?

> 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)

Reply via email to