Return-Path: X-Original-To: apmail-incubator-drill-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-drill-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9438A17C8B for ; Wed, 12 Nov 2014 04:11:19 +0000 (UTC) Received: (qmail 124 invoked by uid 500); 12 Nov 2014 04:11:19 -0000 Delivered-To: apmail-incubator-drill-commits-archive@incubator.apache.org Received: (qmail 99958 invoked by uid 500); 12 Nov 2014 04:11:19 -0000 Mailing-List: contact drill-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: drill-commits@incubator.apache.org Delivered-To: mailing list drill-commits@incubator.apache.org Received: (qmail 99832 invoked by uid 99); 12 Nov 2014 04:11:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Nov 2014 04:11:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 55A3CA0F199; Wed, 12 Nov 2014 04:11:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jacques@apache.org To: drill-commits@incubator.apache.org Date: Wed, 12 Nov 2014 04:11:19 -0000 Message-Id: <81a27790b7a84c4d8e8b15a6fecd93a2@git.apache.org> In-Reply-To: <18cba4a1b9fa4c32b36b75130cb6c4bc@git.apache.org> References: <18cba4a1b9fa4c32b36b75130cb6c4bc@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/16] incubator-drill git commit: DRILL-1660: adding a test case to cover an array of empty and null valued objects. i) remove redundant guard statement from JsonRecordReader2 ii) rename unit test suite DRILL-1660: adding a test case to cover an array of empty and null valued objects. i) remove redundant guard statement from JsonRecordReader2 ii) rename unit test suite Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/0cddfc22 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/0cddfc22 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/0cddfc22 Branch: refs/heads/master Commit: 0cddfc2228859bb636dcf6ed03a227626f69e480 Parents: 23d5c38 Author: Hanifi Gunes Authored: Tue Nov 11 15:46:10 2014 -0800 Committer: Hanifi Gunes Committed: Tue Nov 11 16:14:43 2014 -0800 ---------------------------------------------------------------------- .../exec/store/easy/json/JSONRecordReader2.java | 2 +- .../exec/vector/complex/fn/JsonReaderTests.java | 127 ------------------- .../fn/TestJsonReaderWithSparseFiles.java | 127 +++++++++++++++++++ .../vector/complex/fn/nested-with-nulls.json | 3 +- 4 files changed, 130 insertions(+), 129 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0cddfc22/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader2.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader2.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader2.java index ff7d3f2..d1502d4 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader2.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/json/JSONRecordReader2.java @@ -105,7 +105,7 @@ public class JSONRecordReader2 extends AbstractRecordReader { recordCount = 0; try{ - outside: while(true && recordCount < BaseValueVector.INITIAL_VALUE_ALLOCATION){ + outside: while(recordCount < BaseValueVector.INITIAL_VALUE_ALLOCATION){ writer.setPosition(recordCount); switch(jsonReader.write(writer)){ http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0cddfc22/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/fn/JsonReaderTests.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/fn/JsonReaderTests.java b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/fn/JsonReaderTests.java deleted file mode 100644 index 9a8eedf..0000000 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/fn/JsonReaderTests.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.drill.exec.vector.complex.fn; - - -import java.util.List; -import java.util.Objects; - -import org.apache.drill.BaseTestQuery; -import org.apache.drill.common.expression.SchemaPath; -import org.apache.drill.exec.proto.UserBitShared; -import org.apache.drill.exec.proto.beans.QueryResult; -import org.apache.drill.exec.record.RecordBatchLoader; -import org.apache.drill.exec.rpc.user.QueryResultBatch; -import org.apache.drill.exec.vector.ValueVector; -import org.junit.Test; - -public class JsonReaderTests extends BaseTestQuery { - - static interface Function { - void apply(T param); - } - - protected void query(final String query, final Function testBody) throws Exception { - List batches = testSqlWithResults(query); - RecordBatchLoader loader = new RecordBatchLoader(client.getAllocator()); - try { - QueryResultBatch batch = batches.get(0); - loader.load(batch.getHeader().getDef(), batch.getData()); - - testBody.apply(loader); - - } finally { - for (QueryResultBatch batch:batches) { - batch.release(); - } - loader.clear(); - } - } - - @Test - public void testIfDrillCanReadSparseRecords() throws Exception { - final String sql = "select * from cp.`vector/complex/fn/sparse.json`"; - query(sql, new Function() { - @Override - public void apply(RecordBatchLoader loader) { - assert loader.getRecordCount() == 4 : "invalid record count returned"; - - //XXX: make sure value order matches vector order - final Object[][] values = new Object[][] { - {null, null}, - {1L, null}, - {null, 2L}, - {3L, 3L} - }; - - Object[] row; - Object expected; - Object actual; - for (int r=0;r() { - @Override - public void apply(RecordBatchLoader loader) { - assert loader.getRecordCount() == 3 : "invalid record count returned"; - - //XXX: make sure value order matches vector order - final Object[][] values = new Object[][] { - {"[{},{},{},{\"name\":\"doe\"},{}]"}, - {"[]"}, - {"[{\"name\":\"john\",\"id\":10}]"}, - }; - - Object[] row; - Object expected; - Object actual; - for (int r=0;r { + void apply(T param); + } + + protected void query(final String query, final Function testBody) throws Exception { + List batches = testSqlWithResults(query); + RecordBatchLoader loader = new RecordBatchLoader(client.getAllocator()); + try { + // first batch at index 0 is empty and used for fast schema return. Load the second one for the tests + QueryResultBatch batch = batches.get(1); + loader.load(batch.getHeader().getDef(), batch.getData()); + testBody.apply(loader); + } finally { + for (QueryResultBatch batch:batches) { + batch.release(); + } + loader.clear(); + } + } + + @Test + public void testIfDrillCanReadSparseRecords() throws Exception { + final String sql = "select * from cp.`vector/complex/fn/sparse.json`"; + query(sql, new Function() { + @Override + public void apply(RecordBatchLoader loader) { + assert loader.getRecordCount() == 4 : "invalid record count returned"; + + //XXX: make sure value order matches vector order + final Object[][] values = new Object[][] { + {null, null}, + {1L, null}, + {null, 2L}, + {3L, 3L} + }; + + Object[] row; + Object expected; + Object actual; + for (int r=0;r() { + @Override + public void apply(RecordBatchLoader loader) { + assert loader.getRecordCount() == 4 : "invalid record count returned"; + + //XXX: make sure value order matches vector order + final Object[][] values = new Object[][] { + {"[{},{},{},{\"name\":\"doe\"},{}]"}, + {"[]"}, + {"[{\"name\":\"john\",\"id\":10}]"}, + {"[{},{}]"}, + }; + + Object[] row; + Object expected; + Object actual; + for (int r=0;r