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 <arina.yelchiyeva@gmail.com>
Authored: Thu May 18 10:55:48 2017 +0000
Committer: Aman Sinha <asinha@maprtech.com>
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<UnionAll>
{
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);
+ }
+ }
}
|