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/07 04:44:46 UTC
git commit: TAJO-897: PartitionedTableRewriter is repeated several
times with same table. (Hyoungjun Kim via hyunsik)
Repository: tajo
Updated Branches:
refs/heads/master eae4c1323 -> 844ffd7d2
TAJO-897: PartitionedTableRewriter is repeated several times with same table. (Hyoungjun Kim via hyunsik)
Closes #54
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/844ffd7d
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/844ffd7d
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/844ffd7d
Branch: refs/heads/master
Commit: 844ffd7d2428209292e41dadbfed19ee03c37deb
Parents: eae4c13
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Jul 7 11:40:38 2014 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Jul 7 11:43:31 2014 +0900
----------------------------------------------------------------------
CHANGES | 3 +++
.../rewrite/PartitionedTableRewriter.java | 19 +++----------
.../query/TestJoinOnPartitionedTables.java | 28 ++++++++++++++++++++
3 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/844ffd7d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d12b1e8..986af7a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -74,6 +74,9 @@ Release 0.9.0 - unreleased
BUG FIXES
+ TAJO-897: PartitionedTableRewriter is repeated several times with same
+ table. (Hyoungjun Kim via hyunsik)
+
TAJO-891: Complex join conditions with UNION or inline should be supported.
(hyunsik)
http://git-wip-us.apache.org/repos/asf/tajo/blob/844ffd7d/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/PartitionedTableRewriter.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/PartitionedTableRewriter.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/PartitionedTableRewriter.java
index e637341..666c5fc 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/PartitionedTableRewriter.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/PartitionedTableRewriter.java
@@ -76,21 +76,8 @@ public class PartitionedTableRewriter implements RewriteRule {
@Override
public LogicalPlan rewrite(LogicalPlan plan) throws PlanningException {
- boolean containsPartitionedTables;
- for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) {
- containsPartitionedTables = false;
- for (RelationNode relation : block.getRelations()) {
- if (relation.getType() == NodeType.SCAN) {
- TableDesc table = ((ScanNode)relation).getTableDesc();
- if (table.hasPartition()) {
- containsPartitionedTables = true;
- }
- }
- }
- if (containsPartitionedTables) {
- rewriter.visit(block, plan, block, block.getRoot(), new Stack<LogicalNode>());
- }
- }
+ LogicalPlan.QueryBlock rootBlock = plan.getRootBlock();
+ rewriter.visit(rootBlock, plan, rootBlock, rootBlock.getRoot(), new Stack<LogicalNode>());
return plan;
}
@@ -360,7 +347,7 @@ public class PartitionedTableRewriter implements RewriteRule {
updateTableStat(rewrittenScanNode);
// if it is topmost node, set it as the rootnode of this block.
- if (stack.empty()) {
+ if (stack.empty() || block.getRoot().equals(scanNode)) {
block.setRoot(rewrittenScanNode);
} else {
PlannerUtil.replaceNode(plan, stack.peek(), scanNode, rewrittenScanNode);
http://git-wip-us.apache.org/repos/asf/tajo/blob/844ffd7d/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinOnPartitionedTables.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinOnPartitionedTables.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinOnPartitionedTables.java
index 781f80a..34ead13 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinOnPartitionedTables.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinOnPartitionedTables.java
@@ -24,6 +24,8 @@ import org.junit.Test;
import java.sql.ResultSet;
+import static org.junit.Assert.assertEquals;
+
public class TestJoinOnPartitionedTables extends QueryTestCaseBase {
public TestJoinOnPartitionedTables() {
@@ -64,6 +66,32 @@ public class TestJoinOnPartitionedTables extends QueryTestCaseBase {
}
@Test
+ public void testPartitionMultiplePartitionFilter() throws Exception {
+ executeDDL("customer_ddl.sql", null);
+ ResultSet res = executeFile("insert_into_customer.sql");
+ res.close();
+
+ res = executeString(
+ "select a.c_custkey, b.c_custkey from " +
+ " (select c_custkey, c_nationkey from customer_parts where c_nationkey < 0 " +
+ " union all " +
+ " select c_custkey, c_nationkey from customer_parts where c_nationkey < 0 " +
+ ") a " +
+ "left outer join customer_parts b " +
+ "on a.c_custkey = b.c_custkey " +
+ "and a.c_nationkey > 0"
+ );
+
+ String expected =
+ "c_custkey,c_custkey\n" +
+ "-------------------------------\n";
+ assertEquals(expected, resultSetToString(res));
+ res.close();
+
+ executeString("DROP TABLE customer_parts PURGE").close();
+ }
+
+ @Test
public void testFilterPushDownPartitionColumnCaseWhen() throws Exception {
executeDDL("customer_ddl.sql", null);
ResultSet res = executeFile("insert_into_customer.sql");