You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Vitalii Diravka (JIRA)" <ji...@apache.org> on 2018/10/11 14:58:00 UTC

[jira] [Resolved] (DRILL-3214) Config option to cast empty string to null does not cast empty string to null

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

Vitalii Diravka resolved DRILL-3214.
------------------------------------
       Resolution: Won't Fix
         Assignee: Vitalii Diravka  (was: Sean Hsuan-Yi Chu)
    Fix Version/s:     (was: 1.1.0)
                   1.0.0

The option doesn't work on SESSION level. It should be resolved in DRILL-3259:
{code}
0: jdbc:drill:zk=local> alter session set `drill.exec.functions.cast_empty_string_to_null` = true;
+-------+----------------------------------------------------------+
|  ok   |                         summary                          |
+-------+----------------------------------------------------------+
| true  | drill.exec.functions.cast_empty_string_to_null updated.  |
+-------+----------------------------------------------------------+
1 row selected (0.064 seconds)
0: jdbc:drill:zk=local> SELECT cast('' as int) FROM (VALUES(1));
Error: SYSTEM ERROR: NumberFormatException: 

[Error Id: 4e7f8752-ec87-47c4-8ac9-15850bbd4c70 on vitalii-pc:31010] (state=,code=0)
{code}

But the option works on SYSTEM level:
{code}
[Error Id: 58265ead-b835-4772-89b9-1a90bce3c7e0 on vitalii-pc:31010] (state=,code=0)
0: jdbc:drill:zk=local> alter system set `drill.exec.functions.cast_empty_string_to_null` = true;
+-------+----------------------------------------------------------+
|  ok   |                         summary                          |
+-------+----------------------------------------------------------+
| true  | drill.exec.functions.cast_empty_string_to_null updated.  |
+-------+----------------------------------------------------------+
1 row selected (0.08 seconds)
0: jdbc:drill:zk=local> SELECT cast('' as int) FROM (VALUES(1));
+---------+
| EXPR$0  |
+---------+
| null    |
+---------+
1 row selected (0.094 seconds)
{code}

[~mrsarm] Could you double check it? If your case differs, feel free to create another ticket to solve that.

> Config option to cast empty string to null does not cast empty string to null
> -----------------------------------------------------------------------------
>
>                 Key: DRILL-3214
>                 URL: https://issues.apache.org/jira/browse/DRILL-3214
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Functions - Drill
>    Affects Versions: 1.0.0
>         Environment: faec150598840c40827e6493992d81209aa936da
>            Reporter: Khurram Faraaz
>            Assignee: Vitalii Diravka
>            Priority: Major
>             Fix For: 1.0.0
>
>
> Config option drill.exec.functions.cast_empty_string_to_null does not seem to be working as designed.
> Disable casting of empty strings to null. 
> {code}
> 0: jdbc:drill:schema=dfs.tmp> alter session set `drill.exec.functions.cast_empty_string_to_null` = false;
> +-------+----------------------------------------------------------+
> |  ok   |                         summary                          |
> +-------+----------------------------------------------------------+
> | true  | drill.exec.functions.cast_empty_string_to_null updated.  |
> +-------+----------------------------------------------------------+
> 1 row selected (0.078 seconds)
> {code}
> In this query we see empty strings are retained in query output in columns[1].
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT columns[0], columns[1], columns[2] from `threeColsDouble.csv`;
> +----------+---------+---------+
> |  EXPR$0  | EXPR$1  | EXPR$2  |
> +----------+---------+---------+
> | 156      | 234     | 12222   |
> | 2653543  | 434     | 0       |
> | 367345   | 567567  | 23      |
> | 34554    | 1234    | 45      |
> | 4345     | 567678  | 19876   |
> | 34556    | 0       | 1109    |
> | 5456     | -1      | 1098    |
> | 6567     |         | 34534   |
> | 7678     | 1       | 6       |
> | 8798     | 456     | 243     |
> | 265354   | 234     | 123     |
> | 367345   |         | 234     |
> | 34554    | 1       | 2       |
> | 4345     | 0       | 10      |
> | 34556    | -1      | 19      |
> | 5456     | 23423   | 345     |
> | 6567     | 0       | 2348    |
> | 7678     | 1       | 2       |
> | 8798     |         | 45      |
> | 099      | 19      | 17      |
> +----------+---------+---------+
> 20 rows selected (0.13 seconds)
> {code}
> Casting empty strings to integer leads to NumberFormatException
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT columns[0], cast(columns[1] as int), columns[2] from `threeColsDouble.csv`;
> Error: SYSTEM ERROR: java.lang.NumberFormatException: 
> Fragment 0:0
> [Error Id: b08f4247-263a-460d-b37b-91a70375f7ba on centos-03.qa.lab:31010] (state=,code=0)
> {code}
> Enable casting empty string to null.
> {code}
> 0: jdbc:drill:schema=dfs.tmp> alter session set `drill.exec.functions.cast_empty_string_to_null` = true;
> +-------+----------------------------------------------------------+
> |  ok   |                         summary                          |
> +-------+----------------------------------------------------------+
> | true  | drill.exec.functions.cast_empty_string_to_null updated.  |
> +-------+----------------------------------------------------------+
> 1 row selected (0.077 seconds)
> {code}
> Run query
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT columns[0], cast(columns[1] as int), columns[2] from `threeColsDouble.csv`;
> Error: SYSTEM ERROR: java.lang.NumberFormatException: 
> Fragment 0:0
> [Error Id: de633399-15f9-4a79-a21f-262bd5551207 on centos-03.qa.lab:31010] (state=,code=0)
> {code}
> Note from the output of below query that the empty strings are not casted to null, although drill.exec.functions.cast_empty_string_to_null was set to true.
> {code}
> 0: jdbc:drill:schema=dfs.tmp> SELECT columns[0], columns[1], columns[2] from `threeColsDouble.csv`;
> +----------+---------+---------+
> |  EXPR$0  | EXPR$1  | EXPR$2  |
> +----------+---------+---------+
> | 156      | 234     | 12222   |
> | 2653543  | 434     | 0       |
> | 367345   | 567567  | 23      |
> | 34554    | 1234    | 45      |
> | 4345     | 567678  | 19876   |
> | 34556    | 0       | 1109    |
> | 5456     | -1      | 1098    |
> | 6567     |         | 34534   |
> | 7678     | 1       | 6       |
> | 8798     | 456     | 243     |
> | 265354   | 234     | 123     |
> | 367345   |         | 234     |
> | 34554    | 1       | 2       |
> | 4345     | 0       | 10      |
> | 34556    | -1      | 19      |
> | 5456     | 23423   | 345     |
> | 6567     | 0       | 2348    |
> | 7678     | 1       | 2       |
> | 8798     |         | 45      |
> | 099      | 19      | 17      |
> +----------+---------+---------+
> 20 rows selected (0.125 seconds)
> {code}



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