tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [03/10] git commit: TAJO-463: Throw PlanningException when Creating table with Partition exception COLUMN. (DaeMyung Kang via hyunsik)
Date Tue, 31 Dec 2013 08:50:55 GMT
TAJO-463: Throw PlanningException when Creating table with Partition exception COLUMN. (DaeMyung
Kang via 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/b574cf8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/b574cf8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/b574cf8c

Branch: refs/heads/DAG-execplan
Commit: b574cf8c46bbcdf2601fc20ef149d08b0a88742f
Parents: 4c75790
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Sun Dec 29 22:02:12 2013 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Sun Dec 29 22:02:12 2013 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  5 ++-
 .../tajo/engine/planner/LogicalPlanner.java     | 29 +++++++++++---
 .../engine/planner/global/GlobalPlanner.java    | 17 +++-----
 .../org/apache/tajo/client/TestTajoClient.java  | 41 +++++++++++++++++---
 4 files changed, 68 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b574cf8c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ff45694..98d392a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -174,7 +174,10 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
-    TAJO-452: Timstamp literal with fractional seconds results in 
+    TAJO-463: Throw PlanningException when Creating table with Partition
+    exception COLUMN. (DaeMyung Kang via hyunsik)
+
+    TAJO-452: Timstamp literal with fractional seconds results in
     java.lang.ArrayIndexOutOfBoundsException. (Keuntae Park via hyunsik)
 
     TAJO-454: pass invalid argument to DateTime constructor in LogicalPlanner.

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b574cf8c/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
index 55f4290..fea3361 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanner.java
@@ -781,12 +781,22 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
 
       return storeNode;
     } else {
-
       Schema tableSchema;
-      if (expr.hasPartition() && expr.getPartition().getPartitionType() == PartitionType.COLUMN
&&
-          ((ColumnPartition)expr.getPartition()).isOmitValues()) {
+      boolean mergedPartition = false;
+      if (expr.hasPartition()) {
+        if (expr.getPartition().getPartitionType().equals(PartitionType.COLUMN)) {
+          if (((ColumnPartition)expr.getPartition()).isOmitValues()) {
+            mergedPartition = true;
+          }
+        } else {
+          throw new PlanningException(String.format("Not supported PartitonType: %s", 
+                                      expr.getPartition().getPartitionType()));
+        }
+      }
+
+      if (mergedPartition) {
         ColumnDefinition [] merged = TUtil.concat(expr.getTableElements(),
-            ((ColumnPartition)expr.getPartition()).getColumns());
+                          ((ColumnPartition)expr.getPartition()).getColumns());
         tableSchema = convertTableElementsSchema(merged);
       } else {
         tableSchema = convertTableElementsSchema(expr.getTableElements());
@@ -808,6 +818,7 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
         // TODO - it should be configurable.
         createTableNode.setStorageType(CatalogProtos.StoreType.CSV);
       }
+
       if (expr.hasParams()) {
         Options options = new Options();
         options.putAll(expr.getParams());
@@ -818,9 +829,15 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
         createTableNode.setPath(new Path(expr.getLocation()));
       }
 
-      if (expr.hasPartition()) {
-        createTableNode.setPartitions(convertTableElementsPartition(context, expr));
+      if (expr.hasPartition()) { 
+        if (expr.getPartition().getPartitionType().equals(PartitionType.COLUMN)) {
+          createTableNode.setPartitions(convertTableElementsPartition(context, expr));
+        } else {
+          throw new PlanningException(String.format("Not supported PartitonType: %s", 
+                                      expr.getPartition().getPartitionType()));
+        }
       }
+
       return createTableNode;
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b574cf8c/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 877a179..5ab53d8 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
@@ -323,7 +323,9 @@ public class GlobalPlanner {
 
   private ExecutionBlock buildStorePlan(GlobalPlanContext context,
                                         ExecutionBlock childBlock,
-                                        StoreTableNode currentNode) {
+                                        StoreTableNode currentNode) 
+    throws PlanningException
+    {
     PartitionDesc partitionDesc = currentNode.getPartitions();
 
     // if result table is not a partitioned table, directly store it
@@ -351,17 +353,8 @@ public class GlobalPlanner {
       channel.setPartitionKey(partitionDesc.getColumns().toArray(columns));
       channel.setSchema(childNode.getOutSchema());
       channel.setStoreType(storeType);
-    } else if (partitionsType == CatalogProtos.PartitionsType.HASH) {
-      channel = new DataChannel(childBlock, currentBlock, HASH_PARTITION,
-          partitionDesc.getNumPartitions());
-      Column[] columns = new Column[partitionDesc.getColumns().size()];
-      channel.setPartitionKey(partitionDesc.getColumns().toArray(columns));
-      channel.setSchema(childNode.getOutSchema());
-      channel.setStoreType(storeType);
-    } else if(partitionsType == CatalogProtos.PartitionsType.RANGE) {
-      // TODO
-    } else if(partitionsType == CatalogProtos.PartitionsType.LIST) {
-      // TODO
+    } else {
+      throw new PlanningException(String.format("Not Supported PartitionsType :%s", partitionsType));
     }
 
     // 3. create a ScanNode for scanning shuffle data

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/b574cf8c/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
index 44004d2..6e33d7c 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/client/TestTajoClient.java
@@ -250,7 +250,7 @@ public class TestTajoClient {
     assertTrue(desc.getStats().getNumBytes() > 0);
   }
 
-  @Test
+  //@Test
   public final void testCreateAndDropTablePartitionedHash1ByExecuteQuery() throws IOException,
       ServiceException, SQLException {
     TajoConf conf = cluster.getConfiguration();
@@ -274,7 +274,7 @@ public class TestTajoClient {
     assertTrue(hdfs.exists(tablePath));
   }
 
-  @Test
+  //@Test
   public final void testCreateAndPurgeTablePartitionedHash1ByExecuteQuery() throws IOException,
       ServiceException, SQLException {
     TajoConf conf = cluster.getConfiguration();
@@ -298,7 +298,7 @@ public class TestTajoClient {
     assertFalse(hdfs.exists(tablePath));
   }
 
-  @Test
+  //@Test
   public final void testCreateAndDropTablePartitionedHash2ByExecuteQuery() throws IOException,
       ServiceException, SQLException {
     TajoConf conf = cluster.getConfiguration();
@@ -322,7 +322,7 @@ public class TestTajoClient {
     assertFalse(hdfs.exists(tablePath));
   }
 
-  @Test
+  //@Test
   public final void testCreateAndDropTablePartitionedListByExecuteQuery() throws IOException,
       ServiceException, SQLException {
     TajoConf conf = cluster.getConfiguration();
@@ -347,7 +347,7 @@ public class TestTajoClient {
     assertFalse(hdfs.exists(tablePath));
   }
 
-  @Test
+  //@Test
   public final void testCreateAndDropTablePartitionedRangeByExecuteQuery() throws IOException,
       ServiceException, SQLException {
     TajoConf conf = cluster.getConfiguration();
@@ -372,6 +372,37 @@ public class TestTajoClient {
     assertFalse(client.existTable(tableName));
     assertFalse(hdfs.exists(tablePath));
   }
+
+  @Test
+  public final void testFailCreateTablePartitionedOtherExceptColumn() throws IOException,
+      ServiceException, SQLException {
+    TajoConf conf = cluster.getConfiguration();
+    final String tableName = "testFailCreateTablePartitionedOtherExceptColumn";
+
+    assertFalse(client.existTable(tableName));
+
+    String rangeSql = "create table " + tableName + " (deptname text, score int4)";
+    rangeSql += "PARTITION BY RANGE (score)";
+    rangeSql += "( PARTITION sub_part1 VALUES LESS THAN (2),";
+    rangeSql += "PARTITION sub_part2 VALUES LESS THAN (5),";
+    rangeSql += "PARTITION sub_part2 VALUES LESS THAN (MAXVALUE) )";
+
+    assertFalse(client.updateQuery(rangeSql));
+ 
+    String listSql = "create table " + tableName + " (deptname text, score int4)";
+    listSql += "PARTITION BY LIST (deptname)";
+    listSql += "( PARTITION sub_part1 VALUES('r&d', 'design'),";
+    listSql += "PARTITION sub_part2 VALUES('sales', 'hr') )";
+
+    assertFalse(client.updateQuery(listSql));
+
+    String hashSql = "create table " + tableName + " (deptname text, score int4)";
+    hashSql += "PARTITION BY HASH (deptname)";
+    hashSql += "PARTITIONS 2";
+
+    assertFalse(client.updateQuery(hashSql));
+  }
+
   @Test
   public final void testCreateAndDropTablePartitionedColumnByExecuteQuery() throws IOException,
       ServiceException, SQLException {


Mime
View raw message