You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/11/05 21:03:00 UTC

[jira] [Updated] (IMPALA-7805) NumericLiteral toSql() should render zero as 0, not 0-E38, 0.000, etc.

     [ https://issues.apache.org/jira/browse/IMPALA-7805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Rogers updated IMPALA-7805:
--------------------------------
    Description: 
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.

  was:
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.

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


> 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: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org