Return-Path: X-Original-To: apmail-drill-issues-archive@minotaur.apache.org Delivered-To: apmail-drill-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 129B310BC2 for ; Thu, 8 Jan 2015 04:27:34 +0000 (UTC) Received: (qmail 85655 invoked by uid 500); 8 Jan 2015 04:27:35 -0000 Delivered-To: apmail-drill-issues-archive@drill.apache.org Received: (qmail 85618 invoked by uid 500); 8 Jan 2015 04:27:35 -0000 Mailing-List: contact issues-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list issues@drill.apache.org Received: (qmail 85605 invoked by uid 99); 8 Jan 2015 04:27:35 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2015 04:27:35 +0000 Date: Thu, 8 Jan 2015 04:27:35 +0000 (UTC) From: "Sean Hsuan-Yi Chu (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (DRILL-1874) Text reader should allow treating empty fields as NULLs instead of empty string MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DRILL-1874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sean Hsuan-Yi Chu updated DRILL-1874: ------------------------------------- Attachment: DRILL-1874.3.patch This patch passed unit tests, functional and tpch > 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: Improvement > Components: Storage - Text & CSV > Affects Versions: 0.7.0 > Reporter: Aman Sinha > Assignee: Sean Hsuan-Yi Chu > Fix For: 0.8.0 > > Attachments: DRILL-1874.1.patch, DRILL-1874.2.patch, DRILL-1874.3.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)