You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/11/22 23:19:36 UTC

hive git commit: HIVE-14646 : poison metastore APIs to make sure we can fail old clients for backward compat (Sergey Shelukhin)

Repository: hive
Updated Branches:
  refs/heads/hive-14535 05879a8ea -> d00196c19


HIVE-14646 : poison metastore APIs to make sure we can fail old clients for backward compat (Sergey Shelukhin)


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

Branch: refs/heads/hive-14535
Commit: d00196c19fd4fd12db757b99ebb186d344fd3ba3
Parents: 05879a8
Author: Sergey Shelukhin <se...@apache.org>
Authored: Tue Nov 22 15:19:03 2016 -0800
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Tue Nov 22 15:19:31 2016 -0800

----------------------------------------------------------------------
 metastore/if/hive_metastore.thrift                     |  3 ++-
 .../src/gen/thrift/gen-cpp/hive_metastore_types.cpp    |  8 +++++---
 .../src/gen/thrift/gen-cpp/hive_metastore_types.h      |  3 ++-
 .../hadoop/hive/metastore/api/ClientCapability.java    |  5 ++++-
 metastore/src/gen/thrift/gen-php/metastore/Types.php   |  2 ++
 .../src/gen/thrift/gen-py/hive_metastore/ttypes.py     |  3 +++
 .../src/gen/thrift/gen-rb/hive_metastore_types.rb      |  5 +++--
 .../apache/hadoop/hive/metastore/HiveMetaStore.java    | 13 +++++++++++--
 .../hadoop/hive/metastore/HiveMetaStoreClient.java     |  6 ++++--
 9 files changed, 36 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/if/hive_metastore.thrift
----------------------------------------------------------------------
diff --git a/metastore/if/hive_metastore.thrift b/metastore/if/hive_metastore.thrift
index 67dcc9b..6260dad 100755
--- a/metastore/if/hive_metastore.thrift
+++ b/metastore/if/hive_metastore.thrift
@@ -937,7 +937,8 @@ struct GetAllFunctionsResponse {
 }
 
 enum ClientCapability {
-  TEST_CAPABILITY = 1
+  TEST_CAPABILITY = 1,
+  INSERT_ONLY_TABLES = 2
 }
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp b/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
index 17f911f..7f0ca4e 100644
--- a/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
+++ b/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp
@@ -178,12 +178,14 @@ const char* _kFileMetadataExprTypeNames[] = {
 const std::map<int, const char*> _FileMetadataExprType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(1, _kFileMetadataExprTypeValues, _kFileMetadataExprTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
 
 int _kClientCapabilityValues[] = {
-  ClientCapability::TEST_CAPABILITY
+  ClientCapability::TEST_CAPABILITY,
+  ClientCapability::INSERT_ONLY_TABLES
 };
 const char* _kClientCapabilityNames[] = {
-  "TEST_CAPABILITY"
+  "TEST_CAPABILITY",
+  "INSERT_ONLY_TABLES"
 };
-const std::map<int, const char*> _ClientCapability_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(1, _kClientCapabilityValues, _kClientCapabilityNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+const std::map<int, const char*> _ClientCapability_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(2, _kClientCapabilityValues, _kClientCapabilityNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
 
 
 Version::~Version() throw() {

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h b/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
index 236ad15..ee08c76 100644
--- a/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
+++ b/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h
@@ -160,7 +160,8 @@ extern const std::map<int, const char*> _FileMetadataExprType_VALUES_TO_NAMES;
 
 struct ClientCapability {
   enum type {
-    TEST_CAPABILITY = 1
+    TEST_CAPABILITY = 1,
+    INSERT_ONLY_TABLES = 2
   };
 };
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ClientCapability.java
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ClientCapability.java b/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ClientCapability.java
index f53bd82..8fc8311 100644
--- a/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ClientCapability.java
+++ b/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/ClientCapability.java
@@ -12,7 +12,8 @@ import java.util.HashMap;
 import org.apache.thrift.TEnum;
 
 public enum ClientCapability implements org.apache.thrift.TEnum {
-  TEST_CAPABILITY(1);
+  TEST_CAPABILITY(1),
+  INSERT_ONLY_TABLES(2);
 
   private final int value;
 
@@ -35,6 +36,8 @@ public enum ClientCapability implements org.apache.thrift.TEnum {
     switch (value) {
       case 1:
         return TEST_CAPABILITY;
+      case 2:
+        return INSERT_ONLY_TABLES;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-php/metastore/Types.php
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-php/metastore/Types.php b/metastore/src/gen/thrift/gen-php/metastore/Types.php
index 7dfeb44..5d438b8 100644
--- a/metastore/src/gen/thrift/gen-php/metastore/Types.php
+++ b/metastore/src/gen/thrift/gen-php/metastore/Types.php
@@ -169,8 +169,10 @@ final class FileMetadataExprType {
 
 final class ClientCapability {
   const TEST_CAPABILITY = 1;
+  const INSERT_ONLY_TABLES = 2;
   static public $__names = array(
     1 => 'TEST_CAPABILITY',
+    2 => 'INSERT_ONLY_TABLES',
   );
 }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py b/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
index b2e2484..0609c11 100644
--- a/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
+++ b/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
@@ -252,13 +252,16 @@ class FileMetadataExprType:
 
 class ClientCapability:
   TEST_CAPABILITY = 1
+  INSERT_ONLY_TABLES = 2
 
   _VALUES_TO_NAMES = {
     1: "TEST_CAPABILITY",
+    2: "INSERT_ONLY_TABLES",
   }
 
   _NAMES_TO_VALUES = {
     "TEST_CAPABILITY": 1,
+    "INSERT_ONLY_TABLES": 2,
   }
 
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
----------------------------------------------------------------------
diff --git a/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb b/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
index 4a6209f..d6b7666 100644
--- a/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
+++ b/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
@@ -120,8 +120,9 @@ end
 
 module ClientCapability
   TEST_CAPABILITY = 1
-  VALUE_MAP = {1 => "TEST_CAPABILITY"}
-  VALID_VALUES = Set.new([TEST_CAPABILITY]).freeze
+  INSERT_ONLY_TABLES = 2
+  VALUE_MAP = {1 => "TEST_CAPABILITY", 2 => "INSERT_ONLY_TABLES"}
+  VALID_VALUES = Set.new([TEST_CAPABILITY, INSERT_ONLY_TABLES]).freeze
 end
 
 class Version

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index f20ef4c..7ef810f 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -1926,6 +1926,10 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       Exception ex = null;
       try {
         t = get_table_core(dbname, name);
+        if (MetaStoreUtils.isInsertOnlyTable(t.getParameters())) {
+          assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
+              "insert-only tables", "get_table_req");
+        }
         firePreEvent(new PreReadTableEvent(t, this));
       } catch (MetaException e) {
         ex = e;
@@ -2028,8 +2032,7 @@ public class HiveMetaStore extends ThriftHiveMetastore {
         if (dbName == null || dbName.isEmpty()) {
           throw new UnknownDBException("DB name is null or empty");
         }
-        if (tableNames == null)
-        {
+        if (tableNames == null) {
           throw new InvalidOperationException(dbName + " cannot find null tables");
         }
 
@@ -2054,6 +2057,12 @@ public class HiveMetaStore extends ThriftHiveMetastore {
           tables.addAll(ms.getTableObjectsByName(dbName, distinctTableNames.subList(startIndex, endIndex)));
           startIndex = endIndex;
         }
+        for (Table t : tables) {
+          if (MetaStoreUtils.isInsertOnlyTable(t.getParameters())) {
+            assertClientHasCapability(capabilities, ClientCapability.INSERT_ONLY_TABLES,
+                "insert-only tables", "get_table_req");
+          }
+        }
       } catch (Exception e) {
         ex = e;
         if (e instanceof MetaException) {

http://git-wip-us.apache.org/repos/asf/hive/blob/d00196c1/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index f698125..013c656 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -99,9 +99,11 @@ public class HiveMetaStoreClient implements IMetaStoreClient {
    * doesn't have (e.g. a getting a table of a new type), it will get back failures when the
    * capability checking is enabled (the default).
    */
-  public final static ClientCapabilities VERSION = null; // No capabilities.
+  public final static ClientCapabilities VERSION = new ClientCapabilities(
+      Lists.newArrayList(ClientCapability.INSERT_ONLY_TABLES));
+  // Test capability for tests.
   public final static ClientCapabilities TEST_VERSION = new ClientCapabilities(
-      Lists.newArrayList(ClientCapability.TEST_CAPABILITY)); // Test capability for tests.
+      Lists.newArrayList(ClientCapability.INSERT_ONLY_TABLES, ClientCapability.TEST_CAPABILITY));
 
   ThriftHiveMetastore.Iface client = null;
   private TTransport transport = null;