You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by me...@apache.org on 2015/04/14 02:16:35 UTC
[2/2] drill git commit: DRILL-2707: Fix HashJoinBatch to set output
type to be optional while performing full outer join
DRILL-2707: Fix HashJoinBatch to set output type to be optional while performing full outer join
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/ea2c9efb
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/ea2c9efb
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/ea2c9efb
Branch: refs/heads/master
Commit: ea2c9efb993fa29317ee846839d57d1c54be6168
Parents: cc752c1
Author: Mehant Baid <me...@gmail.com>
Authored: Mon Apr 13 11:26:50 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Mon Apr 13 14:28:51 2015 -0700
----------------------------------------------------------------------
.../exec/physical/impl/join/HashJoinBatch.java | 8 ++-
.../impl/join/TestHashJoinAdvanced.java | 65 +++++++++++++++++++
.../physical/impl/join/TestJoinComplex.java | 52 ---------------
.../parquet/drill-2707_required_types.parquet | Bin 0 -> 264 bytes
4 files changed, 70 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/ea2c9efb/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 bbd83c0..6400d8b 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
@@ -413,9 +413,9 @@ public class HashJoinBatch extends AbstractRecordBatch<HashJoinPOP> {
MajorType inputType = field.getType();
MajorType outputType;
- // If left join, then the output type must be nullable. However, map types are
+ // If left or full outer 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
+ if ((joinType == JoinRelType.LEFT || joinType == JoinRelType.FULL) && inputType.getMode() == DataMode.REQUIRED
&& inputType.getMinorType() != TypeProtos.MinorType.MAP) {
outputType = Types.overrideMode(inputType, DataMode.OPTIONAL);
} else {
@@ -451,7 +451,9 @@ public class HashJoinBatch extends AbstractRecordBatch<HashJoinPOP> {
MajorType inputType = vv.getField().getType();
MajorType outputType;
- if (joinType == JoinRelType.RIGHT && inputType.getMode() == DataMode.REQUIRED) {
+
+ // If right or full outer join then the output type should be optional
+ if ((joinType == JoinRelType.RIGHT || joinType == JoinRelType.FULL) && inputType.getMode() == DataMode.REQUIRED) {
outputType = Types.overrideMode(inputType, DataMode.OPTIONAL);
} else {
outputType = inputType;
http://git-wip-us.apache.org/repos/asf/drill/blob/ea2c9efb/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
new file mode 100644
index 0000000..782ea6c
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinAdvanced.java
@@ -0,0 +1,65 @@
+/**
+ * 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 TestHashJoinAdvanced 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();
+ }
+
+ @Test
+ public void testFOJWithRequiredTypes() throws Exception {
+ String query = "select t1.varchar_col from " +
+ "cp.`parquet/drill-2707_required_types.parquet` t1 full outer join cp.`parquet/alltypes.json` t2 " +
+ "on t1.int_col = t2.INT_col order by t1.varchar_col limit 1";
+
+ testBuilder()
+ .sqlQuery(query)
+ .ordered()
+ .baselineColumns("varchar_col")
+ .baselineValues("doob")
+ .go();
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/ea2c9efb/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
deleted file mode 100644
index cdda10e..0000000
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestJoinComplex.java
+++ /dev/null
@@ -1,52 +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.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/ea2c9efb/exec/java-exec/src/test/resources/parquet/drill-2707_required_types.parquet
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/drill-2707_required_types.parquet b/exec/java-exec/src/test/resources/parquet/drill-2707_required_types.parquet
new file mode 100644
index 0000000..2299f38
Binary files /dev/null and b/exec/java-exec/src/test/resources/parquet/drill-2707_required_types.parquet differ