Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D84CB200CA6 for ; Tue, 9 May 2017 07:03:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D7011160BBF; Tue, 9 May 2017 05:03:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 27858160BC7 for ; Tue, 9 May 2017 07:03:08 +0200 (CEST) Received: (qmail 79278 invoked by uid 500); 9 May 2017 05:03:07 -0000 Mailing-List: contact dev-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 dev@drill.apache.org Received: (qmail 79231 invoked by uid 99); 9 May 2017 05:03:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 May 2017 05:03:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id AAD011AF949 for ; Tue, 9 May 2017 05:03:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id yUvSbCE8Ikuo for ; Tue, 9 May 2017 05:03:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 65D2F5FCAC for ; Tue, 9 May 2017 05:03:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D179FE0D19 for ; Tue, 9 May 2017 05:03:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 41AB821DFC for ; Tue, 9 May 2017 05:03:04 +0000 (UTC) Date: Tue, 9 May 2017 05:03:04 +0000 (UTC) From: "Paul Rogers (JIRA)" To: dev@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DRILL-5491) NPE when reading a CSV file, with headers, but blank header line MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 09 May 2017 05:03:09 -0000 Paul Rogers created DRILL-5491: ---------------------------------- Summary: NPE when reading a CSV file, with headers, but blank header line Key: DRILL-5491 URL: https://issues.apache.org/jira/browse/DRILL-5491 Project: Apache Drill Issue Type: Bug Affects Versions: 1.8.0 Reporter: Paul Rogers See DRILL-5490 for background. Try this unit test case: {code} FixtureBuilder builder = ClusterFixture.builder() .maxParallelization(1); try (ClusterFixture cluster = builder.build(); ClientFixture client = cluster.clientFixture()) { TextFormatConfig csvFormat = new TextFormatConfig(); csvFormat.fieldDelimiter = ','; csvFormat.skipFirstLine = false; csvFormat.extractHeader = true; cluster.defineWorkspace("dfs", "data", "/tmp/data", "csv", csvFormat); String sql = "SELECT * FROM `dfs.data`.`csv/test7.csv`"; client.queryBuilder().sql(sql).printCsv(); } } {code} The test can also be run as a query using your favorite client. Using this input file: {code} a,b,c d,e,f {code} (The first line is blank.) The following is the result: {code} Exception (no rows returned): org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: NullPointerException {code} The {{RepeatedVarCharOutput}} class tries (but fails for the reasons outlined in DRILL-5490) to detect this case. The code crashes here in {{CompliantTextRecordReader.extractHeader()}}: {code} String [] fieldNames = ((RepeatedVarCharOutput)hOutput).getTextOutput(); {code} Because of bad code in {{RepeatedVarCharOutput.getTextOutput()}}: {code} public String [] getTextOutput () throws ExecutionSetupException { if (recordCount == 0 || fieldIndex == -1) { return null; } if (this.recordStart != characterData) { throw new ExecutionSetupException("record text was requested before finishing record"); } {code} Since there is no text on the line, special code elsewhere (see DRILL-5490) elects not to increment the {{recordCount}}. (BTW: {{recordCount}} is the total across-batch count, probably the in-batch count, {{batchIndex}}, was wanted here.) Since the count is zero, we return null. But, if the author probably thought we'd get a zero-length record, and the if-statement throws an exception in this case. But, see DRILL-5490 about why this code does not actually work. The result is one bug (not incrementing the record count), triggering another (returning a null), which masks a third ({{recordStart}} is not set correctly so the exception would not be thrown.) All that bad code is just fun and games until we get an NPE, however. -- This message was sent by Atlassian JIRA (v6.3.15#6346)