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 E6EBE200C84 for ; Mon, 29 May 2017 23:14:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E5EE1160BCE; Mon, 29 May 2017 21:14:10 +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 38F6C160BD6 for ; Mon, 29 May 2017 23:14:10 +0200 (CEST) Received: (qmail 86358 invoked by uid 500); 29 May 2017 21:14:09 -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 86347 invoked by uid 99); 29 May 2017 21:14:09 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 May 2017 21:14:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id CE2431802CA for ; Mon, 29 May 2017 21:14:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-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-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id oxDGQMBWD2BZ for ; Mon, 29 May 2017 21:14:08 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 534075FDBE for ; Mon, 29 May 2017 21:14:07 +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 732D4E0C1B for ; Mon, 29 May 2017 21:14:06 +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 3351321B58 for ; Mon, 29 May 2017 21:14:05 +0000 (UTC) Date: Mon, 29 May 2017 21:14:05 +0000 (UTC) From: "Paul Rogers (JIRA)" To: dev@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DRILL-5548) SELECT * against an empty CSV file with headers produces error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 29 May 2017 21:14:11 -0000 Paul Rogers created DRILL-5548: ---------------------------------- Summary: SELECT * against an empty CSV file with headers produces error Key: DRILL-5548 URL: https://issues.apache.org/jira/browse/DRILL-5548 Project: Apache Drill Issue Type: Bug Affects Versions: 1.10.0 Reporter: Paul Rogers Priority: Minor Drill's CSV column reader supports two forms of files: * Files with column headers as the first line of the file. * Files without column headers. The CSV storage plugin specifies which format to use for files accessed via that storage plugin config. Suppose we have a empty file. When queried in the CSV configuration without headers, the query works. The schema returned is the {{columns}} Varchar array, and the results contain no rows. Good. Now, query the same file with the CSV plugin configured to use headers. {code} TextFormatConfig csvFormat = new TextFormatConfig(); csvFormat.fieldDelimiter = ','; csvFormat.skipFirstLine = false; csvFormat.extractHeader = true; {code} (The above can also be done using JSON when running Drill as a server.) We get the following exception: {code} org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: IllegalStateException: Incoming batch [#4, ProjectRecordBatch] has an empty schema. This is not allowed. {code} This particular case is a bit tricky. First, we want headers, but there are none. We can interpret this as an error (a file with headers must have headers). Or, we an treat it as a file that happens to have no columns. The latter choice is a bit more general. The file also has no data rows. This could be an error, or it too could just be treated as a result set of zero rows. Combined, the result set is one with no columns and no rows: an empty result set. This is actually a valid (if not very useful) result in SQL. Conversation with Jinfeng suggested that, in such a scenario, the reader is supposed to make up a dummy column so that the result is not empty. While this is a workaround, it seems to just push the problem from the Project operator into each of many record readers. -- This message was sent by Atlassian JIRA (v6.3.15#6346)