drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject drill git commit: DRILL-2197: Fix no applicable constructor error in outer join with a map type
Date Thu, 19 Feb 2015 23:13:47 GMT
Repository: drill
Updated Branches:
  refs/heads/master d4dc295f1 -> 1ceddff66


DRILL-2197: Fix no applicable constructor error in outer join with a map type


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/1ceddff6
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/1ceddff6
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/1ceddff6

Branch: refs/heads/master
Commit: 1ceddff66d4d81344417af6563a09e756b34d9eb
Parents: d4dc295
Author: Parth Chandra <pchandra@maprtech.com>
Authored: Wed Feb 18 22:13:49 2015 -0800
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Thu Feb 19 11:01:48 2015 -0800

----------------------------------------------------------------------
 .../exec/physical/impl/join/HashJoinBatch.java  |  6 ++-
 .../physical/impl/join/TestJoinComplex.java     | 52 ++++++++++++++++++++
 .../resources/join/DRILL-2197-result-1.json     |  2 +
 .../resources/join/DRILL-2197-result-2.json     |  2 +
 .../src/test/resources/join/complex_1.json      | 39 +++++++++++++++
 .../src/test/resources/join/complex_2.json      | 19 +++++++
 6 files changed, 119 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinBatch.java
index dae8a03..43d46af 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinBatch.java
@@ -23,6 +23,7 @@ import java.util.List;
 import org.apache.drill.common.expression.FieldReference;
 import org.apache.drill.common.logical.data.JoinCondition;
 import org.apache.drill.common.logical.data.NamedExpression;
+import org.apache.drill.common.types.TypeProtos;
 import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.Types;
@@ -412,7 +413,10 @@ public class HashJoinBatch extends AbstractRecordBatch<HashJoinPOP>
{
 
         MajorType inputType = field.getType();
         MajorType outputType;
-        if (joinType == JoinRelType.LEFT && inputType.getMode() == DataMode.REQUIRED)
{
+        // If left join, then the output type must be nullable. However, map types are
+        // not nullable so we must exclude them from the check below (see DRILL-2197).
+        if (joinType == JoinRelType.LEFT && inputType.getMode() == DataMode.REQUIRED
+            && inputType.getMinorType() != TypeProtos.MinorType.MAP) {
           outputType = Types.overrideMode(inputType, DataMode.OPTIONAL);
         } else {
           outputType = inputType;

http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestJoinComplex.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestJoinComplex.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestJoinComplex.java
new file mode 100644
index 0000000..cdda10e
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestJoinComplex.java
@@ -0,0 +1,52 @@
+/**
+ * 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.physical.impl.join;
+
+
+import org.apache.drill.BaseTestQuery;
+import org.junit.Test;
+
+public class TestJoinComplex extends BaseTestQuery {
+
+
+  @Test //DRILL-2197 Left Self Join with complex type in projection
+  public void testLeftSelfHashJoinWithMap() throws Exception {
+    final String query = " select a.id, b.oooi.oa.oab.oabc oabc, b.ooof.oa.oab oab from cp.`join/complex_1.json`
a left outer join cp.`join/complex_1.json` b on a.id=b.id order by a.id";
+
+    testBuilder()
+      .sqlQuery(query)
+      .unOrdered()
+      .jsonBaselineFile("join/DRILL-2197-result-1.json")
+      .build()
+      .run();
+  }
+
+  @Test //DRILL-2197 Left Join with complex type in projection
+  public void testLeftHashJoinWithMap() throws Exception {
+    final String query = " select a.id, b.oooi.oa.oab.oabc oabc, b.ooof.oa.oab oab from cp.`join/complex_1.json`
a left outer join cp.`join/complex_2.json` b on a.id=b.id order by a.id";
+
+    testBuilder()
+      .sqlQuery(query)
+      .unOrdered()
+      .jsonBaselineFile("join/DRILL-2197-result-2.json")
+      .build()
+      .run();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/test/resources/join/DRILL-2197-result-1.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/join/DRILL-2197-result-1.json b/exec/java-exec/src/test/resources/join/DRILL-2197-result-1.json
new file mode 100644
index 0000000..3fceeb5
--- /dev/null
+++ b/exec/java-exec/src/test/resources/join/DRILL-2197-result-1.json
@@ -0,0 +1,2 @@
+{"id":1, "oabc":1, "oab":{"oabc":1.5678}}
+{"id":2, "oabc":2, "oab":{"oabc":2.5678}}

http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/test/resources/join/DRILL-2197-result-2.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/join/DRILL-2197-result-2.json b/exec/java-exec/src/test/resources/join/DRILL-2197-result-2.json
new file mode 100644
index 0000000..29a3022
--- /dev/null
+++ b/exec/java-exec/src/test/resources/join/DRILL-2197-result-2.json
@@ -0,0 +1,2 @@
+{"id":1, "oabc":1, "oab":{"oabc":1.5678}}
+{"id":2, "oabc":null, "oab":{}}

http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/test/resources/join/complex_1.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/join/complex_1.json b/exec/java-exec/src/test/resources/join/complex_1.json
new file mode 100644
index 0000000..01afc12
--- /dev/null
+++ b/exec/java-exec/src/test/resources/join/complex_1.json
@@ -0,0 +1,39 @@
+{"id":1,
+    "gbyi":0,
+    "gbyt":"soa",
+    "fl":1.6789,
+    "nul":"not null",
+    "bool":false,
+    "str":"This is row 1",
+    "sia":[1, 11, 101, 1001],
+    "sfa":[0.0, 1.01, 10.222, 10.0006789],
+    "sba":[-1, -9.8766, null, true, "text row 1"],
+    "soa":[{"in":1},{"in":1,"fl":1.12345}, {"in":1, "fl":10.12345, "nul":"not null"}, {"in":1,
"fl":10.6789, "nul":"not null", "bool":true, "str":"here is a string at row 1"}],
+    "ooa":[{"in":1}, {"fl":{"f1":1.6789, "f2":54331.0}, "in":1}, {"a":{"aa":{"aaa":"aaa 1"}},
"b":{"bb":{"bbb":"bbb 1"}, "c":{"cc":"ccc 1"}}}],
+    "aaa":[[["aa0 1"], ["ab0 1"]], [["ba0 1"], ["bb0 1"]],[["ca0 1", "ca1 1"],["cb0 1", "cb1
1", "cb2 1"]]],
+    "saa":[-1, [-10, -9.3211], [1, [10.12345, "not null"], [1, 1.6789, "not null", true],
[-1, 6779.0, "not null", false, "this is a short string 1"]]],
+    "oooi":{"oa":{"oab":{"oabc":1}}},
+    "ooof":{"oa":{"oab":{"oabc":1.5678}}},
+    "ooos":{"oa":{"oab":{"oabc":"ooos string 1"}}},
+    "oooa":{"oa":{"oab":{"oabc":[{"rowId":1}, {"rowValue1":1, "rowValue2":1}]}}}
+}
+{"id":2,
+    "gbyi":14,
+    "gbyt":"oooa",
+    "fl":2.6789,
+    "nul":null,
+    "bool":true,
+    "str":"This is row 2",
+    "sia":[2, 12, 102, 1002],
+    "sfa":[0.0, 2.01, 20.222, 20.0006789],
+    "sba":[-2, -19.8766, null, false, "text row 2"],
+    "soa":[{"in":2},{"in":2,"fl":2.12345}, {"in":2, "fl":20.12345, "nul":"not null"}, {"in":2,
"fl":20.6789, "nul":null, "bool":false, "str":"here is a string at row 2"}],
+    "ooa":[{"in":2}, {"fl":{}, "in":2}, {"a":{"aa":{"aaa":"aaa 2"}}, "b":{"bb":{"bbb":"bbb
2"}, "c":{"cc":"ccc 2"}}}],
+    "aaa":[[["aa0 2"], ["ab0 2"]], [["ba0 2"], ["bb0 2"]],[["ca0 2", "ca1 2"],["cb0 2", "cb1
2", "cb2 2"]]],
+    "saa":[-2, [-20, -19.3211], [2, [20.12345, "not null"], [2, 2.6789, "not null", true],
[-2, 6769.0, null, false, "this is a short string 2"]]],
+    "oooi":{"oa":{"oab":{"oabc":2}}},
+    "ooof":{"oa":{"oab":{"oabc":2.5678}}},
+    "ooos":{"oa":{"oab":{"oabc":"ooos string 2"}}},
+    "oooa":{"oa":{"oab":{"oabc":[{"rowId":2}, {"rowValue1":2, "rowValue2":2}]}}}
+}
+

http://git-wip-us.apache.org/repos/asf/drill/blob/1ceddff6/exec/java-exec/src/test/resources/join/complex_2.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/join/complex_2.json b/exec/java-exec/src/test/resources/join/complex_2.json
new file mode 100644
index 0000000..b46f9a0
--- /dev/null
+++ b/exec/java-exec/src/test/resources/join/complex_2.json
@@ -0,0 +1,19 @@
+{"id":1,
+    "gbyi":0,
+    "gbyt":"soa",
+    "fl":1.6789,
+    "nul":"not null",
+    "bool":false,
+    "str":"This is row 1",
+    "sia":[1, 11, 101, 1001],
+    "sfa":[0.0, 1.01, 10.222, 10.0006789],
+    "sba":[-1, -9.8766, null, true, "text row 1"],
+    "soa":[{"in":1},{"in":1,"fl":1.12345}, {"in":1, "fl":10.12345, "nul":"not null"}, {"in":1,
"fl":10.6789, "nul":"not null", "bool":true, "str":"here is a string at row 1"}],
+    "ooa":[{"in":1}, {"fl":{"f1":1.6789, "f2":54331.0}, "in":1}, {"a":{"aa":{"aaa":"aaa 1"}},
"b":{"bb":{"bbb":"bbb 1"}, "c":{"cc":"ccc 1"}}}],
+    "aaa":[[["aa0 1"], ["ab0 1"]], [["ba0 1"], ["bb0 1"]],[["ca0 1", "ca1 1"],["cb0 1", "cb1
1", "cb2 1"]]],
+    "saa":[-1, [-10, -9.3211], [1, [10.12345, "not null"], [1, 1.6789, "not null", true],
[-1, 6779.0, "not null", false, "this is a short string 1"]]],
+    "oooi":{"oa":{"oab":{"oabc":1}}},
+    "ooof":{"oa":{"oab":{"oabc":1.5678}}},
+    "ooos":{"oa":{"oab":{"oabc":"ooos string 1"}}},
+    "oooa":{"oa":{"oab":{"oabc":[{"rowId":1}, {"rowValue1":1, "rowValue2":1}]}}}
+}


Mime
View raw message