You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2014/07/11 08:14:25 UTC
git commit: TAJO-929: Broadcast join with empty outer join table
returns empty result. (Hyoungjun Kim via hyunsik)
Repository: tajo
Updated Branches:
refs/heads/master 42f3b4dd8 -> 329e508ca
TAJO-929: Broadcast join with empty outer join table returns empty result. (Hyoungjun Kim via hyunsik)
Closes #66
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/329e508c
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/329e508c
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/329e508c
Branch: refs/heads/master
Commit: 329e508caf88b3f75e465581599a255eceabb16a
Parents: 42f3b4d
Author: Hyunsik Choi <hy...@apache.org>
Authored: Fri Jul 11 15:13:05 2014 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Fri Jul 11 15:13:11 2014 +0900
----------------------------------------------------------------------
CHANGES | 5 +++-
.../tajo/master/querymaster/Repartitioner.java | 11 ++++++---
.../tajo/engine/query/TestJoinBroadcast.java | 26 ++++++++++++++++++++
3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/329e508c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 0694eba..921183e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -82,7 +82,10 @@ Release 0.9.0 - unreleased
BUG FIXES
- TAJO-927: Broadcast Join with Large, Small, Large, Small tables
+ TAJO-929: Broadcast join with empty outer join table returns empty result.
+ (Hyoungjun Kim via hyunsik)
+
+ TAJO-927: Broadcast Join with Large, Small, Large, Small tables
makes a wrong plan. (Hyoungjun Kim via hyunsik)
TAJO-913: Add some missed tests for constant value group-by keys.
http://git-wip-us.apache.org/repos/asf/tajo/blob/329e508c/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java
index fc80bd1..ce2194e 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java
@@ -119,13 +119,18 @@ public class Repartitioner {
}
}
- // If one of inner join tables has no input data, it should return zero rows.
+ // If one of inner join tables has no input data, it means that this execution block has no result row.
JoinNode joinNode = PlannerUtil.findMostBottomNode(execBlock.getPlan(), NodeType.JOIN);
if (joinNode != null) {
if ( (joinNode.getJoinType() == JoinType.INNER)) {
+ LogicalNode leftNode = joinNode.getLeftChild();
+ LogicalNode rightNode = joinNode.getRightChild();
for (int i = 0; i < stats.length; i++) {
- if (stats[i] == 0) {
- return;
+ if (scans[i].getPID() == leftNode.getPID() || scans[i].getPID() == rightNode.getPID()) {
+ if (stats[i] == 0) {
+ LOG.info(scans[i] + " 's input data is zero. Inner join's result is empty.");
+ return;
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/329e508c/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinBroadcast.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinBroadcast.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinBroadcast.java
index 668992b..e01b3c5 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinBroadcast.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinBroadcast.java
@@ -504,6 +504,32 @@ public class TestJoinBroadcast extends QueryTestCaseBase {
}
}
+ @Test
+ public final void testInnerAndOuterWithEmpty() throws Exception {
+ executeDDL("customer_partition_ddl.sql", null);
+ executeFile("insert_into_customer_partition.sql").close();
+
+ // outer join table is empty
+ ResultSet res = executeString(
+ "select a.l_orderkey, b.o_orderkey, c.c_custkey from lineitem a " +
+ "inner join orders b on a.l_orderkey = b.o_orderkey " +
+ "left outer join customer_broad_parts c on a.l_orderkey = c.c_custkey and c.c_custkey < 0"
+ );
+
+ String expected = "l_orderkey,o_orderkey,c_custkey\n" +
+ "-------------------------------\n" +
+ "1,1,null\n" +
+ "1,1,null\n" +
+ "2,2,null\n" +
+ "3,3,null\n" +
+ "3,3,null\n";
+
+ assertEquals(expected, resultSetToString(res));
+ res.close();
+
+ executeString("DROP TABLE customer_broad_parts PURGE").close();
+ }
+
static interface TupleCreator {
public Tuple createTuple(String[] columnDatas);
}