Repository: drill
Updated Branches:
  refs/heads/master cc752c1a9 -> 3b5a87e89


DRILL-2771: Fix hash join to use required type for projecting map types in the 
right outer join case.


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

Branch: refs/heads/master
Commit: 3b5a87e89e55c14bb792ae2d0e7429e34cb035a9
Parents: ea2c9ef
Author: Mehant Baid <meha...@gmail.com>
Authored: Mon Apr 13 14:17:34 2015 -0700
Committer: Mehant Baid <meha...@gmail.com>
Committed: Mon Apr 13 14:28:51 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/physical/impl/join/HashJoinBatch.java   |  6 ++++--
 .../exec/physical/impl/join/TestHashJoinAdvanced.java  | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/3b5a87e8/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 6400d8b..b2fae8d 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
@@ -452,8 +452,10 @@ public class HashJoinBatch extends 
AbstractRecordBatch<HashJoinPOP> {
         MajorType inputType = vv.getField().getType();
         MajorType outputType;
 
-        // If right or full outer join then the output type should be optional
-        if ((joinType == JoinRelType.RIGHT || joinType == JoinRelType.FULL) && 
inputType.getMode() == DataMode.REQUIRED) {
+        // If right or full outer join then the output type should be 
optional. However, map types are
+        // not nullable so we must exclude them from the check below (see 
DRILL-2771, DRILL-2197).
+        if ((joinType == JoinRelType.RIGHT || joinType == JoinRelType.FULL) && 
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/3b5a87e8/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
index 782ea6c..796f6fe 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
@@ -62,4 +62,17 @@ public class TestHashJoinAdvanced extends BaseTestQuery {
         .baselineValues("doob")
         .go();
   }
+
+  @Test  // DRILL-2771, similar problem as DRILL-2197 except problem 
reproduces with right outer join instead of left
+  public void testRightJoinWithMap() 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` b right outer join cp.`join/complex_1.json` 
a on a.id = b.id order by a.id";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .jsonBaselineFile("join/DRILL-2197-result-1.json")
+        .build()
+        .run();
+  }
 }

Reply via email to