You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2013/12/28 07:36:17 UTC

[20/50] [abbrv] git commit: TAJO-426: HCatalogStore created partitions automatically. (jaehwa)

TAJO-426: HCatalogStore created partitions automatically. (jaehwa)


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

Branch: refs/heads/DAG-execplan
Commit: 4dbecf90161465b2818093fe8544b35f86b888aa
Parents: 2c53ccc
Author: blrunner <jh...@gruter.com>
Authored: Wed Dec 18 20:25:11 2013 +0900
Committer: blrunner <jh...@gruter.com>
Committed: Wed Dec 18 20:25:11 2013 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../tajo/catalog/store/HCatalogStore.java       | 20 ++++++++++----------
 .../tajo/catalog/store/TestHCatalogStore.java   |  5 +++--
 3 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4dbecf90/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 83f39ab..5d6ba59 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -155,6 +155,8 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-426: HCatalogStore created partitions automatically. (jaehwa)
+
     TAJO-418: sort operator after inline views consisting of unions can cause 
     an incorrect distributed plan. (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4dbecf90/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
index 4dd60e5..e7a862a 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/main/java/org/apache/tajo/catalog/store/HCatalogStore.java
@@ -175,18 +175,19 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
         }
       }
 
+      // set partition keys
       if (table.getPartitionKeys() != null) {
-        partitions = new Partitions();
-        List<FieldSchema> partitionKeys = table.getPartitionKeys();
-        for(int i = 0; i < partitionKeys.size(); i++) {
-          FieldSchema fieldSchema = partitionKeys.get(i);
-          TajoDataTypes.Type dataType = HCatalogUtil.getTajoFieldType(fieldSchema.getType().toString());
-          partitions.addColumn(new Column(fieldSchema.getName(), dataType));
+        if (table.getPartitionKeys().size() > 0) {
+          partitions = new Partitions();
+          List<FieldSchema> partitionKeys = table.getPartitionKeys();
+          for(int i = 0; i < partitionKeys.size(); i++) {
+            FieldSchema fieldSchema = partitionKeys.get(i);
+            TajoDataTypes.Type dataType = HCatalogUtil.getTajoFieldType(fieldSchema.getType().toString());
+            partitions.addColumn(new Column(fieldSchema.getName(), dataType));
+          }
+          partitions.setPartitionsType(CatalogProtos.PartitionsType.COLUMN);
         }
-        partitions.setPartitionsType(CatalogProtos.PartitionsType.COLUMN);
       }
-
-
     } finally {
       HCatUtil.closeHiveClientQuietly(client);
     }
@@ -199,7 +200,6 @@ public class HCatalogStore extends CatalogConstants implements CatalogStore {
     if (partitions != null) {
       tableDesc.setPartitions(partitions);
     }
-
     return tableDesc;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/4dbecf90/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
index 8b13646..d8ee85e 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hcatalog/src/test/java/org/apache/tajo/catalog/store/TestHCatalogStore.java
@@ -44,8 +44,7 @@ import org.junit.Test;
 import java.io.IOException;
 import java.util.*;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * TestHCatalogStore. Test case for
@@ -249,6 +248,7 @@ public class TestHCatalogStore {
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(6).getDataType().getType());
     assertEquals("c_comment", columns.get(7).getColumnName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(7).getDataType().getType());
+    assertNull(table.getPartitions());
 
     table = store.getTable(DB_NAME + "." + NATION);
     columns = table.getSchema().getColumns();
@@ -264,6 +264,7 @@ public class TestHCatalogStore {
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(3).getDataType().getType());
     assertEquals("type", columns.get(4).getColumnName());
     assertEquals(TajoDataTypes.Type.TEXT, columns.get(4).getDataType().getType());
+    assertNotNull(table.getPartitions());
     assertEquals("type", table.getPartitions().getColumn(0).getColumnName());
     assertEquals(CatalogProtos.PartitionsType.COLUMN, table.getPartitions().getPartitionsType());
   }