From commits-return-4913-apmail-drill-commits-archive=drill.apache.org@drill.apache.org Sat May 20 14:26:01 2017 Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22CB51A2A0 for ; Sat, 20 May 2017 14:26:01 +0000 (UTC) Received: (qmail 85769 invoked by uid 500); 20 May 2017 14:26:01 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 85687 invoked by uid 500); 20 May 2017 14:26:01 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 85586 invoked by uid 99); 20 May 2017 14:26:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 May 2017 14:26:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 85A3CDF97F; Sat, 20 May 2017 14:26:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: amansinha@apache.org To: commits@drill.apache.org Date: Sat, 20 May 2017 14:26:05 -0000 Message-Id: <2f92f10d10e54183b4e2cef641d11d55@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [6/6] drill git commit: DRILL-5523: Revert if condition in UnionAllRecordBatch changed in DRILL-5419 DRILL-5523: Revert if condition in UnionAllRecordBatch changed in DRILL-5419 close apache/drill#842 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/416ec70a Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/416ec70a Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/416ec70a Branch: refs/heads/master Commit: 416ec70a616e8d12b5c7fca809763b977d2f7aad Parents: f21edb0 Author: Arina Ielchiieva Authored: Thu May 18 10:55:48 2017 +0000 Committer: Aman Sinha Committed: Fri May 19 10:42:05 2017 -0700 ---------------------------------------------------------------------- .../impl/union/UnionAllRecordBatch.java | 12 ++++++++++- .../vector/complex/writer/TestJsonReader.java | 21 +++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/416ec70a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java index 985c4ae..e6a0dd4 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java @@ -204,7 +204,17 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { MajorType outputFieldType = outputFields.get(index).getType(); MaterializedField outputField = MaterializedField.create(outputPath.getAsUnescapedPath(), outputFieldType); - if (outputFields.get(index).getPath().equals(inputPath.getAsUnescapedPath())) { + /* + todo: Fix if condition when DRILL-4824 is merged + If condition should be changed to: + `if (outputFields.get(index).getPath().equals(inputPath.getAsUnescapedPath())) {` + DRILL-5419 has changed condition to correct one but this caused regression (DRILL-5521). + Root cause is missing indication of child column in map types when it is null. + DRILL-4824 is re-working json reader implementation, including map types and will fix this problem. + Reverting condition to previous one to avoid regression till DRILL-4824 is merged. + Unit test - TestJsonReader.testKvgenWithUnionAll(). + */ + if (outputFields.get(index).getPath().equals(inputPath)) { ValueVector vvOut = container.addOrGet(outputField); TransferPair tp = vvIn.makeTransferPair(vvOut); transfers.add(tp); http://git-wip-us.apache.org/repos/asf/drill/blob/416ec70a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestJsonReader.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestJsonReader.java b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestJsonReader.java index 78c2c4c..7c0b345 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestJsonReader.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestJsonReader.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -721,4 +721,23 @@ public class TestJsonReader extends BaseTestQuery { testNoResult("alter session reset `exec.enable_union_type`"); } } + + @Test // DRILL-5521 + public void testKvgenWithUnionAll() throws Exception { + File directory = new File(BaseTestQuery.getTempDir("json/input")); + try { + directory.mkdirs(); + String fileName = "map.json"; + try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(directory, fileName)))) { + writer.write("{\"rk\": \"a\", \"m\": {\"a\":\"1\"}}"); + } + + String query = String.format("select kvgen(m) as res from (select m from dfs_test.`%s/%s` union all " + + "select convert_from('{\"a\" : null}' ,'json') as m from (values(1)))", directory.toPath().toString(), fileName); + assertEquals("Row count should match", 2, testSql(query)); + + } finally { + org.apache.commons.io.FileUtils.deleteQuietly(directory); + } + } }