You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Sean Hsuan-Yi Chu (JIRA)" <ji...@apache.org> on 2015/01/02 22:27:35 UTC

[jira] [Assigned] (DRILL-1874) Text reader should allow treating empty fields as NULLs instead of empty string

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

Sean Hsuan-Yi Chu reassigned DRILL-1874:
----------------------------------------

    Assignee: Aman Sinha  (was: Sean Hsuan-Yi Chu)

> 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
>          Components: Storage - Text & CSV
>    Affects Versions: 0.7.0
>            Reporter: Aman Sinha
>            Assignee: Aman Sinha
>         Attachments: DRILL-1874.1.patch
>
>
> 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)