You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by si...@apache.org on 2015/01/03 02:02:49 UTC
tajo git commit: TAJO-1275: Optimizer pushs down non-equi filter as
theta join qualifier
Repository: tajo
Updated Branches:
refs/heads/master 5a97079ce -> 9e329a550
TAJO-1275: Optimizer pushs down non-equi filter as theta join qualifier
Closes #327
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/9e329a55
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/9e329a55
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/9e329a55
Branch: refs/heads/master
Commit: 9e329a5509b71fa412299169dd3c866e54f46c77
Parents: 5a97079
Author: Keuntae Park <si...@apache.org>
Authored: Fri Jan 2 17:45:46 2015 +0900
Committer: Keuntae Park <si...@apache.org>
Committed: Fri Jan 2 17:45:46 2015 +0900
----------------------------------------------------------------------
CHANGES | 3 +++
.../tajo/engine/planner/TestLogicalPlanner.java | 5 +++-
.../apache/tajo/engine/query/TestJoinQuery.java | 28 ++++++++++++++++++++
...stCrossJoinWithThetaJoinConditionInWhere.sql | 2 ++
...stInnerJoinWithThetaJoinConditionInWhere.sql | 3 +++
...ftOuterJoinWithThetaJoinConditionInWhere.sql | 3 +++
...htOuterJoinWithThetaJoinConditionInWhere.sql | 3 +++
...rossJoinWithThetaJoinConditionInWhere.result | 12 +++++++++
...nnerJoinWithThetaJoinConditionInWhere.result | 7 +++++
...uterJoinWithThetaJoinConditionInWhere.result | 4 +++
...uterJoinWithThetaJoinConditionInWhere.result | 4 +++
.../plan/rewrite/rules/FilterPushDownRule.java | 16 +++++++++++
12 files changed, 89 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 653cdfc..547f373 100644
--- a/CHANGES
+++ b/CHANGES
@@ -134,6 +134,9 @@ Release 0.9.1 - unreleased
BUG FIXES
+ TAJO-1275: Optimizer pushs down non-equi filter as theta join qualifier.
+ (Keuntae Park)
+
TAJO-1249: Tajo should check if a file format given in DDL is supported.
(DaeMyung Kang via hyunsik)
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
index 180033d..889d61c 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
@@ -644,7 +644,10 @@ public class TestLogicalPlanner {
, new FieldEval(new Column("default.t.n_nationkey", Type.INT4))
, new FieldEval(new Column("default.s.s_suppkey", Type.INT4))
);
- joinQualMap.put(joinQual, Boolean.FALSE);
+
+ /* following code is commented because theta join is not supported yet
+ * TODO It SHOULD be restored after TAJO-742 is resolved. */
+ //joinQualMap.put(joinQual, Boolean.FALSE);
LogicalNode[] nodes = PlannerUtil.findAllNodes(node, NodeType.JOIN);
for(LogicalNode eachNode : nodes) {
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
index 223ea8e..ecd933d 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
@@ -121,6 +121,34 @@ public class TestJoinQuery extends QueryTestCaseBase {
}
@Test
+ public final void testCrossJoinWithThetaJoinConditionInWhere() throws Exception {
+ ResultSet res = executeQuery();
+ assertResultSet(res);
+ cleanupQuery(res);
+ }
+
+ @Test
+ public final void testInnerJoinWithThetaJoinConditionInWhere() throws Exception {
+ ResultSet res = executeQuery();
+ assertResultSet(res);
+ cleanupQuery(res);
+ }
+
+ @Test
+ public final void testLeftOuterJoinWithThetaJoinConditionInWhere() throws Exception {
+ ResultSet res = executeQuery();
+ assertResultSet(res);
+ cleanupQuery(res);
+ }
+
+ @Test
+ public final void testRightOuterJoinWithThetaJoinConditionInWhere() throws Exception {
+ ResultSet res = executeQuery();
+ assertResultSet(res);
+ cleanupQuery(res);
+ }
+
+ @Test
public final void testWhereClauseJoin1() throws Exception {
ResultSet res = executeQuery();
assertResultSet(res);
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/queries/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.sql
new file mode 100644
index 0000000..4e20e16
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.sql
@@ -0,0 +1,2 @@
+select a.r_name as a_name, b.r_name as b_name from region a, region b
+where a_name < b_name;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/queries/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.sql
new file mode 100644
index 0000000..90f4822
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.sql
@@ -0,0 +1,3 @@
+select a.r_regionkey, a.r_name, b.r_name from region a join region b
+on a.r_regionkey = b.r_regionkey
+where a.r_name <= b.r_name;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.sql
new file mode 100644
index 0000000..f9160c5
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.sql
@@ -0,0 +1,3 @@
+select * from region a left outer join customer b
+on a.r_regionkey = b.c_custkey
+where a.r_name < b.c_name;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/queries/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.sql
new file mode 100644
index 0000000..10d9918
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.sql
@@ -0,0 +1,3 @@
+select * from region a right outer join customer b
+on a.r_regionkey = b.c_custkey
+where a.r_name < b.c_name;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/results/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.result b/tajo-core/src/test/resources/results/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.result
new file mode 100644
index 0000000..82b2757
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testCrossJoinWithThetaJoinConditionInWhere.result
@@ -0,0 +1,12 @@
+a_name,b_name
+-------------------------------
+AFRICA,AMERICA
+AFRICA,ASIA
+AFRICA,EUROPE
+AFRICA,MIDDLE EAST
+AMERICA,ASIA
+AMERICA,EUROPE
+AMERICA,MIDDLE EAST
+ASIA,EUROPE
+ASIA,MIDDLE EAST
+EUROPE,MIDDLE EAST
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/results/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.result b/tajo-core/src/test/resources/results/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.result
new file mode 100644
index 0000000..b388d0b
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testInnerJoinWithThetaJoinConditionInWhere.result
@@ -0,0 +1,7 @@
+r_regionkey,r_name,r_name
+-------------------------------
+0,AFRICA,AFRICA
+1,AMERICA,AMERICA
+2,ASIA,ASIA
+3,EUROPE,EUROPE
+4,MIDDLE EAST,MIDDLE EAST
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.result b/tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.result
new file mode 100644
index 0000000..c727791
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithThetaJoinConditionInWhere.result
@@ -0,0 +1,4 @@
+r_regionkey,r_name,r_comment,c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment
+-------------------------------
+1,AMERICA,hs use ironic, even requests. s,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
+2,ASIA,ges. thinly even pinto beans ca,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-core/src/test/resources/results/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.result b/tajo-core/src/test/resources/results/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.result
new file mode 100644
index 0000000..c727791
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testRightOuterJoinWithThetaJoinConditionInWhere.result
@@ -0,0 +1,4 @@
+r_regionkey,r_name,r_comment,c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment
+-------------------------------
+1,AMERICA,hs use ironic, even requests. s,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
+2,ASIA,ges. thinly even pinto beans ca,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9e329a55/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
index 15750a1..ef5e7b6 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/rewrite/rules/FilterPushDownRule.java
@@ -210,6 +210,21 @@ public class FilterPushDownRule extends BasicLogicalPlanVisitor<FilterPushDownCo
}
}
+ /* non-equi filter should not be push down as a join qualifier until theta join is implemented
+ * TODO this code SHOULD be restored after TAJO-742 is resolved. */
+ List<EvalNode> thetaJoinFilter = new ArrayList<EvalNode>();
+ for (EvalNode eachEval: context.pushingDownFilters) {
+ if (eachEval.getType() != EvalType.EQUAL) {
+ if (EvalTreeUtil.isJoinQual(block,
+ joinNode.getLeftChild().getOutSchema(),
+ joinNode.getRightChild().getOutSchema(),
+ eachEval, true)) {
+ thetaJoinFilter.add(eachEval);
+ }
+ }
+ }
+ context.pushingDownFilters.removeAll(thetaJoinFilter);
+
// get evals from ON clause
List<EvalNode> onConditions = new ArrayList<EvalNode>();
if (joinNode.hasJoinQual()) {
@@ -344,6 +359,7 @@ public class FilterPushDownRule extends BasicLogicalPlanVisitor<FilterPushDownCo
}
context.pushingDownFilters.addAll(outerJoinFilterEvalsExcludePredication);
+ context.pushingDownFilters.addAll(thetaJoinFilter);
return joinNode;
}