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/10/31 19:22:00 UTC

[jira] [Updated] (IMPALA-7793) CASE statement does not handle NULL from UDF overflow

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

Paul Rogers updated IMPALA-7793:
--------------------------------
    Description: 
The test suite {{QueryTest/decimal-exprs}} contains the following test:

{code:sql}
set decimal_v2=false;
set ENABLE_EXPR_REWRITES=false;
select coalesce(1.8, cast(0 as decimal(38,38)))
{code}

Which produces this result:

{noformat}
+------------------------------------------+
| coalesce(1.8, cast(0 as decimal(38,38))) |
+------------------------------------------+
| 0.00000000000000000000000000000000000000 |
+------------------------------------------+
WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
{noformat}

Notice that the "1.8" overflowed when being put into a {{DECIMAL(38,38)}} type. (The precision and range are both 38, meaning all digits are after the decimal point.)

The {{coalesce()}} function caught the overflow, treated it as a {{NULL}}, and selected the second value from the list, which is 0.

Very good. Now, try the equivalent CASE form (from MPALA-7655):

{noformat}
select CASE WHEN 1.8 IS NOT NULL THEN 1.8 ELSE cast(0 as decimal(38,38)) END;

+-----------------------------------------------------------------------+
| case when 1.8 is not null then 1.8 else cast(0 as decimal(38,38)) end |
+-----------------------------------------------------------------------+
| NULL                                                                  |
+-----------------------------------------------------------------------+
WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
{noformat}

Apparently, the overflow somehow caused the {{ELSE}} clause to not fire.

This one is likely a bug in the BE code generation. Though, tried the {{CASE}} query with a variety of options:

{noformat}
set disable_codegen=true;

and

set disable_codegen=false;
set disable_codegen_rows_threshold=0;

and

set disable_codegen_rows_threshold=10;
{noformat}

In all cases, the {{CASE}} produced the wrong result. Also tried wrapping the expression {{1.8 IS NOT NULL}} in a variety of forms: {{IS TRUE}}, {{IS NOT FALSE}}. None of this worked correctly.

The result of this bug is the the above-mentioned test case fails in a build that contains IMPALA-7655.

  was:
The test suite {{QueryTest/decimal-exprs}} contains the following test:

{code:sql}
set decimal_v2=false;
set ENABLE_EXPR_REWRITES=false;
select coalesce(1.8, cast(0 as decimal(38,38)))
{code}

Which produces this result:

{noformat}
+------------------------------------------+
| coalesce(1.8, cast(0 as decimal(38,38))) |
+------------------------------------------+
| 0.00000000000000000000000000000000000000 |
+------------------------------------------+
WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
{noformat}

Notice that the "1.8" overflowed when being put into a {{DECIMAL(38,38)}} type. (The precision and range are both 38, meaning all digits are after the decimal point.)

The {{coalesce()}} function caught the overflow, treated it as a {{NULL}}, and selected the second value from the list, which is 0.

Very good. Now, try the equivalent CASE form (from MPALA-7655):

{noformat}
select CASE WHEN 1.8 IS NOT NULL THEN 1.8 ELSE cast(0 as decimal(38,38)) END;

+-----------------------------------------------------------------------+
| case when 1.8 is not null then 1.8 else cast(0 as decimal(38,38)) end |
+-----------------------------------------------------------------------+
| NULL                                                                  |
+-----------------------------------------------------------------------+
WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
{noformat}

Apparently, the overflow somehow caused the {{ELSE}} clause to not fire.

This one is likely a bug in the BE code generation. Though, tried the {{CASE}} query with a variety of options:

{noformat}
set disable_codegen=true;

and

set disable_codegen=false;
set disable_codegen_rows_threshold=0;

and

set disable_codegen_rows_threshold=10;
{noformat}

In all cases, the {{CASE}} produced the wrong result. Also tried wrapping the expression {{1.8 IS NOT NULL}} in a variety of forms: {{IS TRUE}}, {{IS NOT FALSE}}. None of this worked correctly.

The result of this bug is the the above-mentioned test case fails in a build that contains MPALA-7655.


> CASE statement does not handle NULL from UDF overflow
> -----------------------------------------------------
>
>                 Key: IMPALA-7793
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7793
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 3.0
>            Reporter: Paul Rogers
>            Priority: Major
>
> The test suite {{QueryTest/decimal-exprs}} contains the following test:
> {code:sql}
> set decimal_v2=false;
> set ENABLE_EXPR_REWRITES=false;
> select coalesce(1.8, cast(0 as decimal(38,38)))
> {code}
> Which produces this result:
> {noformat}
> +------------------------------------------+
> | coalesce(1.8, cast(0 as decimal(38,38))) |
> +------------------------------------------+
> | 0.00000000000000000000000000000000000000 |
> +------------------------------------------+
> WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
> {noformat}
> Notice that the "1.8" overflowed when being put into a {{DECIMAL(38,38)}} type. (The precision and range are both 38, meaning all digits are after the decimal point.)
> The {{coalesce()}} function caught the overflow, treated it as a {{NULL}}, and selected the second value from the list, which is 0.
> Very good. Now, try the equivalent CASE form (from MPALA-7655):
> {noformat}
> select CASE WHEN 1.8 IS NOT NULL THEN 1.8 ELSE cast(0 as decimal(38,38)) END;
> +-----------------------------------------------------------------------+
> | case when 1.8 is not null then 1.8 else cast(0 as decimal(38,38)) end |
> +-----------------------------------------------------------------------+
> | NULL                                                                  |
> +-----------------------------------------------------------------------+
> WARNINGS: UDF WARNING: Decimal expression overflowed, returning NULL
> {noformat}
> Apparently, the overflow somehow caused the {{ELSE}} clause to not fire.
> This one is likely a bug in the BE code generation. Though, tried the {{CASE}} query with a variety of options:
> {noformat}
> set disable_codegen=true;
> and
> set disable_codegen=false;
> set disable_codegen_rows_threshold=0;
> and
> set disable_codegen_rows_threshold=10;
> {noformat}
> In all cases, the {{CASE}} produced the wrong result. Also tried wrapping the expression {{1.8 IS NOT NULL}} in a variety of forms: {{IS TRUE}}, {{IS NOT FALSE}}. None of this worked correctly.
> The result of this bug is the the above-mentioned test case fails in a build that contains IMPALA-7655.



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