tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject tajo git commit: TAJO-2180: Disable unsetting timezone property in HiveCatalogStore.
Date Mon, 29 Aug 2016 12:19:29 GMT
Repository: tajo
Updated Branches:
  refs/heads/master fc147cf06 -> d3ab63bed


TAJO-2180: Disable unsetting timezone property in HiveCatalogStore.

Closes #1048

Signed-off-by: Jinho Kim <jhkim@apache.org>


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

Branch: refs/heads/master
Commit: d3ab63bed6fc8ffe9c6a81141a4f019909892380
Parents: fc147cf
Author: Lee Dongjin <dongjin@apache.org>
Authored: Mon Aug 29 21:18:37 2016 +0900
Committer: Jinho Kim <jhkim@apache.org>
Committed: Mon Aug 29 21:18:37 2016 +0900

----------------------------------------------------------------------
 CHANGES                                              |  3 +++
 .../org/apache/tajo/catalog/CatalogConstants.java    |  5 +++++
 .../apache/tajo/catalog/store/HiveCatalogStore.java  | 15 ++++++++++++---
 .../apache/tajo/catalog/store/AbstractDBStore.java   |  3 +--
 4 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/d3ab63be/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 85fccd0..956e0d4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -21,6 +21,9 @@ Release 0.12.0 - unreleased
 
   IMPROVEMENT
 
+    TAJO-2180: Disable unsetting timezone property in HiveCatalogStore.
+    (Lee Dongjin via jinho)
+
     TAJO-2170: Disable unsetting timezone property. (Lee Dongjin via jinho)
 
     TAJO-2175: Fix some glitches in source code. (Lee Dongjin via jihoon)

http://git-wip-us.apache.org/repos/asf/tajo/blob/d3ab63be/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
index 6acbc34..9c58815 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogConstants.java
@@ -18,6 +18,10 @@
 
 package org.apache.tajo.catalog;
 
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
 public class CatalogConstants {
   // Linux and BSD's max username length is 32. For compatibility with other systems, we
should follow it.
   public final static int MAX_USERNAME_LENGTH = 32;
@@ -58,4 +62,5 @@ public class CatalogConstants {
   public static final String COL_PARTITION_BYTES = "NUM_BYTES";
 
   public static final String INFORMATION_SCHEMA_DB_NAME = "information_schema";
+  protected static final Set<String> UNREMOVABLE_PROPERTY_SET = Sets.newHashSet("timezone");
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/d3ab63be/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
index cecd0f4..755b5d0 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
@@ -19,6 +19,7 @@
 package org.apache.tajo.catalog.store;
 
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -817,10 +818,18 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore
{
     try {
       client = clientPool.getClient();
       Table table = client.getHiveClient().getTable(databaseName, tableName);
-      for (String propertyKey : ProtoUtil.convertStrings(propertyKeys)) {
-        table.getParameters().remove(propertyKey);
+
+      Set<String> keys = Sets.newHashSet(propertyKeys.getValuesList());
+      Set<String> violations = Sets.intersection(keys, UNREMOVABLE_PROPERTY_SET);
+
+      if (!violations.isEmpty()) {
+        throw new UnremovableTablePropertyException(violations.toArray(new String[0]));
+      } else {
+        for (String key : keys) {
+          table.getParameters().remove(key);
+        }
+        client.getHiveClient().alter_table(databaseName, tableName, table);
       }
-      client.getHiveClient().alter_table(databaseName, tableName, table);
     } catch (NoSuchObjectException nsoe) {
     } catch (Exception e) {
       throw new TajoInternalError(e);

http://git-wip-us.apache.org/repos/asf/tajo/blob/d3ab63be/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
index 023dfca..716bbcb 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
@@ -64,7 +64,6 @@ public abstract class AbstractDBStore extends CatalogConstants implements
Catalo
   protected final String connectionPassword;
   protected final String catalogUri;
 
-  protected final Set<String> unremovablePropertySet = Sets.newHashSet("timezone");
   protected final String insertPartitionSql = "INSERT INTO " + TB_PARTTIONS
     + "(" + COL_TABLES_PK + ", PARTITION_NAME, PATH, " + COL_PARTITION_BYTES
     + ") VALUES (?, ? , ?, ?)";
@@ -1121,7 +1120,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements
Catalo
     PreparedStatement pstmt = null;
 
     Set<String> keys = Sets.newHashSet(propertyKeys.getValuesList());
-    Set<String> violations = Sets.intersection(keys, unremovablePropertySet);
+    Set<String> violations = Sets.intersection(keys, UNREMOVABLE_PROPERTY_SET);
 
     if (!violations.isEmpty()) {
       throw new UnremovableTablePropertyException(violations.toArray(new String[0]));


Mime
View raw message