tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-418: sort operator after Inline views consisting of unions can cause an incorrect distributed plan. (hyunsik)
Date Mon, 16 Dec 2013 17:47:21 GMT
Updated Branches:
  refs/heads/master 14160face -> d930a90d5


TAJO-418: sort operator after Inline views consisting of unions can cause an incorrect distributed
plan. (hyunsik)


Project: http://git-wip-us.apache.org/repos/asf/incubator-tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tajo/commit/d930a90d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/d930a90d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/d930a90d

Branch: refs/heads/master
Commit: d930a90d50ce9b41050486ace11c96d0847b80b0
Parents: 14160fa
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Dec 17 02:46:48 2013 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Dec 17 02:46:48 2013 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../engine/planner/global/GlobalPlanner.java    |  7 ++++-
 .../tajo/engine/query/TestCaseByCases.java      | 16 +++++++++++
 .../src/test/queries/tajo418_case.sql           | 29 ++++++++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/d930a90d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2581d3c..96a3b77 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -150,6 +150,9 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-418: sort operator after inline views consisting of unions can cause 
+    an incorrect distributed plan. (hyunsik)
+
     TAJO-417: TestSQLExpression.testCastFromTable causes unit test failure.
     (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/d930a90d/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
index 5ce8922..6ef35ce 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
@@ -288,12 +288,17 @@ public class GlobalPlanner {
     ExecutionBlock currentBlock;
 
     SortNode firstSortNode = PlannerUtil.clone(context.plan.getLogicalPlan(), currentNode);
+    LogicalNode childBlockPlan = childBlock.getPlan();
+    firstSortNode.setChild(childBlockPlan);
+    // sort is a non-projectable operator. So, in/out schemas are the same to its child operator.
+    firstSortNode.setInSchema(childBlockPlan.getOutSchema());
+    firstSortNode.setOutSchema(childBlockPlan.getOutSchema());
     childBlock.setPlan(firstSortNode);
 
     currentBlock = masterPlan.newExecutionBlock();
     DataChannel channel = new DataChannel(childBlock, currentBlock, RANGE_PARTITION, 32);
     channel.setPartitionKey(PlannerUtil.sortSpecsToSchema(currentNode.getSortKeys()).toArray());
-    channel.setSchema(currentNode.getOutSchema());
+    channel.setSchema(firstSortNode.getOutSchema());
 
     ScanNode secondScan = buildInputExecutor(masterPlan.getLogicalPlan(), channel);
     currentNode.setChild(secondScan);

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/d930a90d/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
index 7f301be..5885f10 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
@@ -21,6 +21,7 @@ package org.apache.tajo.engine.query;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.tajo.TpchTestBase;
+import org.apache.tajo.client.ResultSetUtil;
 import org.apache.tajo.util.FileUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -31,6 +32,8 @@ import java.sql.ResultSet;
 import java.util.List;
 import java.util.Map;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 public class TestCaseByCases {
@@ -63,4 +66,17 @@ public class TestCaseByCases {
       res.close();
     }
   }
+
+  @Test
+  public final void testTAJO418Case() throws Exception {
+    ResultSet res = tpch.execute(FileUtil.readTextFile(new File("src/test/queries/tajo418_case.sql")));
+    try {
+      assertTrue(res.next());
+      assertEquals("R", res.getString(1));
+      assertEquals("F", res.getString(2));
+      assertFalse(res.next());
+    } finally {
+      res.close();
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/d930a90d/tajo-core/tajo-core-backend/src/test/queries/tajo418_case.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/queries/tajo418_case.sql b/tajo-core/tajo-core-backend/src/test/queries/tajo418_case.sql
new file mode 100644
index 0000000..b3ad48a
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/queries/tajo418_case.sql
@@ -0,0 +1,29 @@
+SELECT
+  l_returnflag,
+  l_linestatus
+
+FROM (
+  SELECT
+    *
+  FROM
+    lineitem
+  WHERE
+    l_returnflag = 'K'
+
+  UNION ALL
+
+  SELECT
+    *
+  FROM
+    lineitem
+  WHERE
+    l_returnflag = 'R'
+) T
+
+GROUP BY
+  l_returnflag,
+	l_linestatus
+
+ORDER BY
+  l_returnflag,
+	l_linestatus
\ No newline at end of file


Mime
View raw message