Aman Sinha created DRILL-1874:
---------------------------------

             Summary: Text reader should allow treating empty fields as NULLs 
instead of empty string
                 Key: DRILL-1874
                 URL: https://issues.apache.org/jira/browse/DRILL-1874
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 0.7.0
            Reporter: Aman Sinha


The text reader treats a record as a repeated varchar and if there is an empty 
field it produces an empty string.   This prevents CASTing the field to a 
numeric type because one can get a NumberFormatException.   This is a pain 
point for many use cases because empty fields occur frequently in text files. 

Ideally, based on some configuration setting, we should allow treating empty 
fields as NULL values instead of empty string.  This will allow cast to work 
correctly.  

In the meantime, here's a rewrite that can be used as workaround:   
{code}
0: jdbc:drill:zk=local> select case when columns[17] = '' then cast(null as 
int) else cast(columns[17] as int) end  from dfs.tmp.`sample2.tbl`;
+------------+
|   EXPR$0   |
+------------+
| 5          |
| null       |
+------------+
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to