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

ASF subversion and git services commented on IMPALA-7805:
---------------------------------------------------------

Commit b2dbc0f0bc106c89c5722ae909e067c4dabff4d1 in impala's branch 
refs/heads/master from [~paul-rogers]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=b2dbc0f ]

IMPALA-7805: Emit zero as "0" in toSql()

It turns out that Impala has a somewhat Baroque way to represent the
value of a numeric 0.  NumericLiteral.toSql() uses the Java
BigDecimal class to convert a numeric value to a string for use in
explained plans and in verifying expression rewrites.

The default Java behavior is to consider scale when rendering numbers,
including 0. Thus, depending on precision and scale, you may get:

0
0.0
0.00
0.000
...
0E-38

However, mathematically, zero is zero. Plans attach no special meaning
to the extra decimal points or trailing zeros.

To make testing easier, changed the behavior to always emit "0" when the
value is zero, regardless of precision or scale.

Testing: Reran the planner tests and modified captured plans that had
the 0.0, 0.00 variations of zero.

Since this change affects only EXPLAIN output, it cannot affect the
operation of queries. If may impact other tests that compare EXPLAIN
output to a "golden" copy.

Change-Id: I0b2f2f34fe5e6003de407301310ccf433841b9f1
Reviewed-on: http://gerrit.cloudera.org:8080/11878
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> NumericLiteral toSql() should render zero as 0, not 0-E38, 0.000, etc.
> ----------------------------------------------------------------------
>
>                 Key: IMPALA-7805
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7805
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Frontend
>    Affects Versions: Impala 3.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>
> Testing of other issues revealed a somewhat bizarre aspect of how the planner 
> expression nodes render 0. {{NumericLiteral.toSql()}} uses the Java 
> {{BigDecimal}} class to convert a numeric value to a string for use in 
> explained plans.
> The default Java behavior is to consider scale when rendering numbers, 
> including 0. Thus, depending on precision and scale, you may get:
> {noformat}
> 0
> 0.0
> 0.00
> 0.000
> ...
> 0E-38
> {noformat}
> Mathematically, zero is zero. Unlike Java, SQL attaches no significance to 
> the decimal point. (In Java, 0 is an integer, 0.0 is a float.) Nor does SQL 
> attach significance to the number of zeros past the decimal point. And, of 
> course, we're only talking about the output of {{EXPLAIN}}, which is never 
> parsed anyway (except in tests.)
> To make testing easier, change the behavior to always emit "0" when the value 
> is zero, regardless of precision or scale.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to