Repository: kudu
Updated Branches:
  refs/heads/master 7767679a6 -> f54dbb891


KUDU-2191 (10/n): PoC: disallow Kudu alter column, create table operations from 
Hive

This commit makes it more difficult for processes or users who are not
the Kudu Master to alter the columns of Kudu table HMS entries through
Hive APIs.

The bulk of this patch is introducing a new environment context key/pair
('kudu.master_event=true') which is sent by the Kudu Master with every
HMS create/drop/alter table call. The KuduMetastorePlugin checks that
this property is set appropriately when operations modify a Kudu table
HMS entry.

The result is any attempt to create a table through Hive APIs or alter
the columns of a Kudu table through Hive APIs will fail. These
operations can not be supported because Hive lacks the DDL syntax and
HMS APIs to support necessary Kudu-specific table and column options.

It's possible for a user to spoof this environment context entry, but
it's a big enough roadblock that it should prevent accidental DDL
operations.

Change-Id: Idc39b1df07952d37e9ce93f1673aad535767a8ac
Reviewed-on: http://gerrit.cloudera.org:8080/10111
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburk...@apache.org>


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

Branch: refs/heads/master
Commit: f54dbb89183db5559f7dcf76e86239e127f7f023
Parents: 7767679
Author: Dan Burkert <danburk...@apache.org>
Authored: Wed Apr 18 17:18:53 2018 -0700
Committer: Dan Burkert <danburk...@apache.org>
Committed: Thu May 3 20:31:04 2018 +0000

----------------------------------------------------------------------
 .../hive/metastore/KuduMetastorePlugin.java     | 34 +++++++++++++++
 .../hive/metastore/TestKuduMetastorePlugin.java | 44 ++++++++++++++++----
 src/kudu/hms/hms_catalog.cc                     | 19 ++++++---
 src/kudu/hms/hms_catalog.h                      |  4 ++
 src/kudu/hms/hms_client-test.cc                 |  7 +++-
 src/kudu/hms/hms_client.cc                      | 18 ++++----
 src/kudu/hms/hms_client.h                       | 16 ++++---
 src/kudu/integration-tests/master_hms-itest.cc  | 20 +++++----
 8 files changed, 125 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
 
b/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
index 4991f10..7a0a8f2 100644
--- 
a/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
+++ 
b/java/kudu-hive/src/main/java/org/apache/kudu/hive/metastore/KuduMetastorePlugin.java
@@ -17,6 +17,8 @@
 
 package org.apache.kudu.hive.metastore;
 
+import java.util.Map;
+
 import com.google.common.annotations.VisibleForTesting;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.metastore.MetaStoreEventListener;
@@ -27,6 +29,7 @@ import 
org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
 import org.apache.hadoop.hive.metastore.events.AlterTableEvent;
 import org.apache.hadoop.hive.metastore.events.CreateTableEvent;
 import org.apache.hadoop.hive.metastore.events.DropTableEvent;
+import org.apache.hadoop.hive.metastore.events.ListenerEvent;
 
 /**
  * The {@code KuduMetastorePlugin} intercepts DDL operations on Kudu table 
entries
@@ -61,6 +64,8 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
   static final String KUDU_TABLE_ID_KEY = "kudu.table_id";
   @VisibleForTesting
   static final String KUDU_MASTER_ADDRS_KEY = "kudu.master_addresses";
+  @VisibleForTesting
+  static final String KUDU_MASTER_EVENT = "kudu.master_event";
 
   public KuduMetastorePlugin(Configuration config) {
     super(config);
@@ -78,6 +83,10 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
       return;
     }
 
+    if (!isKuduMasterAction(tableEvent)) {
+      throw new MetaException("Kudu tables may not be created through Hive");
+    }
+
     checkKuduProperties(table);
   }
 
@@ -94,6 +103,9 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
       return;
     }
 
+    // The kudu.master_event property isn't checked, because the kudu.table_id
+    // property already implies this event is coming from a Kudu Master.
+
     Table table = tableEvent.getTable();
 
     // Check that the table being dropped is a Kudu table.
@@ -130,6 +142,11 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
     if (!newTableId.equals(oldTableId)) {
       throw new MetaException("Kudu table ID does not match the existing HMS 
entry");
     }
+
+    if (!isKuduMasterAction(tableEvent) &&
+        !oldTable.getSd().getCols().equals(newTable.getSd().getCols())) {
+      throw new MetaException("Kudu table columns may not be altered through 
Hive");
+    }
   }
 
   /**
@@ -187,4 +204,21 @@ public class KuduMetastorePlugin extends 
MetaStoreEventListener {
           KUDU_MASTER_ADDRS_KEY));
     }
   }
+
+  /**
+   * Returns true if the event is from the Kudu Master.
+   */
+  private boolean isKuduMasterAction(ListenerEvent event) {
+    EnvironmentContext environmentContext = event.getEnvironmentContext();
+    if (environmentContext == null) {
+      return false;
+    }
+
+    Map<String, String> properties = environmentContext.getProperties();
+    if (properties == null) {
+      return false;
+    }
+
+    return Boolean.parseBoolean(properties.get(KUDU_MASTER_EVENT));
+  }
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
 
b/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
index 1abcd6a..4d56acb 100644
--- 
a/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
+++ 
b/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
 
 import java.util.UUID;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
@@ -45,6 +46,10 @@ public class TestKuduMetastorePlugin {
   private static HiveConf clientConf;
   private HiveMetaStoreClient client;
 
+  private EnvironmentContext masterContext() {
+    return new 
EnvironmentContext(ImmutableMap.of(KuduMetastorePlugin.KUDU_MASTER_EVENT, 
"true"));
+  }
+
   @BeforeClass
   public static void startMetaStoreServer() throws Exception {
     HiveConf metastoreConf = new HiveConf();
@@ -101,7 +106,6 @@ public class TestKuduMetastorePlugin {
 
   @Test
   public void testCreateTableHandler() throws Exception {
-
     // A non-Kudu table with a Kudu table ID should be rejected.
     try {
       Table table = newTable("table");
@@ -130,26 +134,35 @@ public class TestKuduMetastorePlugin {
     try {
       Table table = newTable("table");
       table.getParameters().remove(KuduMetastorePlugin.KUDU_TABLE_ID_KEY);
-      client.createTable(table);
+      client.createTable(table, masterContext());
       fail();
     } catch (TException e) {
       assertTrue(e.getMessage().contains("Kudu table entry must contain a 
table ID property"));
     }
 
-    // A Kudu table without a master address
+    // A Kudu table without master context.
     try {
       Table table = newTable("table");
-      table.getParameters().remove(KuduMetastorePlugin.KUDU_MASTER_ADDRS_KEY);
       client.createTable(table);
       fail();
     } catch (TException e) {
+      assertTrue(e.getMessage().contains("Kudu tables may not be created 
through Hive"));
+    }
+
+    // A Kudu table without a master address.
+    try {
+      Table table = newTable("table");
+      table.getParameters().remove(KuduMetastorePlugin.KUDU_MASTER_ADDRS_KEY);
+      client.createTable(table, masterContext());
+      fail();
+    } catch (TException e) {
       assertTrue(e.getMessage().contains(
           "Kudu table entry must contain a Master addresses property"));
     }
 
     // Check that creating a valid table is accepted.
     Table table = newTable("table");
-    client.createTable(table);
+    client.createTable(table, masterContext());
     client.dropTable(table.getDbName(), table.getTableName());
   }
 
@@ -157,7 +170,7 @@ public class TestKuduMetastorePlugin {
   public void testAlterTableHandler() throws Exception {
     // Test altering a Kudu table.
     Table table = newTable("table");
-    client.createTable(table);
+    client.createTable(table, masterContext());
     try {
 
       // Try to alter the Kudu table with a different table ID.
@@ -181,6 +194,21 @@ public class TestKuduMetastorePlugin {
 
       // Check that altering the table succeeds.
       client.alter_table(table.getDbName(), table.getTableName(), table);
+
+      // Check that adding a column fails.
+      table.getSd().addToCols(new FieldSchema("b", "int", ""));
+      try {
+        client.alter_table(table.getDbName(), table.getTableName(), table);
+        fail();
+      } catch (TException e) {
+        assertTrue(e.getMessage().contains(
+            "Kudu table columns may not be altered through Hive"));
+      }
+
+      // Check that adding a column succeeds with the master event property 
set.
+      client.alter_table_with_environmentContext(
+          table.getDbName(), table.getTableName(), table,
+          new 
EnvironmentContext(ImmutableMap.of(KuduMetastorePlugin.KUDU_MASTER_EVENT, 
"true")));
     } finally {
       client.dropTable(table.getDbName(), table.getTableName());
     }
@@ -225,7 +253,7 @@ public class TestKuduMetastorePlugin {
   public void testDropTableHandler() throws Exception {
     // Test dropping a Kudu table.
     Table table = newTable("table");
-    client.createTable(table);
+    client.createTable(table, masterContext());
     try {
 
       // Test with an invalid table ID.
@@ -247,7 +275,7 @@ public class TestKuduMetastorePlugin {
     }
 
     // Test dropping a Kudu table with the correct ID.
-    client.createTable(table);
+    client.createTable(table, masterContext());
     EnvironmentContext envContext = new EnvironmentContext();
     envContext.putToProperties(KuduMetastorePlugin.KUDU_TABLE_ID_KEY,
                                
table.getParameters().get(KuduMetastorePlugin.KUDU_TABLE_ID_KEY));

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/hms/hms_catalog.cc
----------------------------------------------------------------------
diff --git a/src/kudu/hms/hms_catalog.cc b/src/kudu/hms/hms_catalog.cc
index 6b01814..9b68ecb 100644
--- a/src/kudu/hms/hms_catalog.cc
+++ b/src/kudu/hms/hms_catalog.cc
@@ -150,11 +150,11 @@ Status HmsCatalog::DropTable(const string& id, const 
string& name) {
     return Status::OK();
   }
 
-  hive::EnvironmentContext env_ctx;
-  env_ctx.__set_properties({ make_pair(HmsClient::kKuduTableIdKey, id) });
+  hive::EnvironmentContext env_ctx = EnvironmentContext();
+  env_ctx.properties.insert(make_pair(HmsClient::kKuduTableIdKey, id));
 
   return Execute([&] (HmsClient* client) {
-    Status s = client->DropTableWithContext(hms_database, hms_table, env_ctx);
+    Status s = client->DropTable(hms_database, hms_table, env_ctx);
     if (s.IsNotFound()) {
       VLOG(1) << "Ignoring missing HMS table entry while dropping table "
               << name << "(" << id << ")";
@@ -242,7 +242,7 @@ Status HmsCatalog::AlterTable(const string& id,
 
       // Overwrite fields in the table that have changed, including the new 
name.
       RETURN_NOT_OK(PopulateTable(id, new_name, schema, master_addresses_, 
&table));
-      return client->AlterTable(hms_database, hms_table, table);
+      return client->AlterTable(hms_database, hms_table, table, 
EnvironmentContext());
   });
 }
 
@@ -465,7 +465,8 @@ Status HmsCatalog::CreateOrUpdateTable(hms::HmsClient* 
client,
                   "will attempt to create a new HMS table entry.";
       hive::Table table;
       RETURN_NOT_OK(PopulateTable(id, name, schema, master_addresses, &table));
-      return client->CreateTable(table);
+
+      return client->CreateTable(table, EnvironmentContext());
   }
 
   // All other errors are fatal.
@@ -490,7 +491,7 @@ Status HmsCatalog::CreateOrUpdateTable(hms::HmsClient* 
client,
     VLOG(1) << "Short-circuiting alter or update table for " << name << " (" 
<< id << ")";
     return Status::OK();
   }
-  return client->AlterTable(hms_database, hms_table, table);
+  return client->AlterTable(hms_database, hms_table, table, 
EnvironmentContext());
 }
 
 Status HmsCatalog::ParseTableName(const string& table,
@@ -558,5 +559,11 @@ bool HmsCatalog::IsEnabled() {
   return !FLAGS_hive_metastore_uris.empty();
 }
 
+hive::EnvironmentContext HmsCatalog::EnvironmentContext() {
+  hive::EnvironmentContext env_ctx;
+  env_ctx.__set_properties({ 
std::make_pair(hms::HmsClient::kKuduMasterEventKey, "true") });
+  return env_ctx;
+}
+
 } // namespace hms
 } // namespace kudu

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/hms/hms_catalog.h
----------------------------------------------------------------------
diff --git a/src/kudu/hms/hms_catalog.h b/src/kudu/hms/hms_catalog.h
index d970a1b..a0374f1 100644
--- a/src/kudu/hms/hms_catalog.h
+++ b/src/kudu/hms/hms_catalog.h
@@ -30,6 +30,7 @@
 #include "kudu/util/status.h"
 
 namespace hive {
+class EnvironmentContext;
 class Table;
 }
 
@@ -134,6 +135,9 @@ class HmsCatalog {
   // Parses a Hive Metastore URI string into a sequence of HostPorts.
   static Status ParseUris(const std::string& metastore_uris, 
std::vector<HostPort>* hostports);
 
+  // Returns a base environment context for use with calls to the HMS.
+  static hive::EnvironmentContext EnvironmentContext();
+
   // Kudu master addresses.
   const std::string master_addresses_;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/hms/hms_client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/hms/hms_client-test.cc b/src/kudu/hms/hms_client-test.cc
index edf8f34..940d66d 100644
--- a/src/kudu/hms/hms_client-test.cc
+++ b/src/kudu/hms/hms_client-test.cc
@@ -71,7 +71,10 @@ class HmsClientTest : public KuduTest,
         make_pair(HmsClient::kStorageHandlerKey, 
HmsClient::kKuduStorageHandler),
     });
 
-    return client->CreateTable(table);
+    hive::EnvironmentContext env_ctx;
+    env_ctx.__set_properties({ make_pair(HmsClient::kKuduMasterEventKey, 
"true") });
+
+    return client->CreateTable(table, env_ctx);
   }
 
   Status DropTable(HmsClient* client,
@@ -80,7 +83,7 @@ class HmsClientTest : public KuduTest,
                    const string& table_id) {
     hive::EnvironmentContext env_ctx;
     env_ctx.__set_properties({ make_pair(HmsClient::kKuduTableIdKey, table_id) 
});
-    return client->DropTableWithContext(database_name, table_name, env_ctx);
+    return client->DropTable(database_name, table_name, env_ctx);
   }
 };
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/hms/hms_client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/hms/hms_client.cc b/src/kudu/hms/hms_client.cc
index 6fe5a46..ca6fdb8 100644
--- a/src/kudu/hms/hms_client.cc
+++ b/src/kudu/hms/hms_client.cc
@@ -114,6 +114,7 @@ namespace hms {
 
 const char* const HmsClient::kKuduTableIdKey = "kudu.table_id";
 const char* const HmsClient::kKuduMasterAddrsKey = "kudu.master_addresses";
+const char* const HmsClient::kKuduMasterEventKey = "kudu.master_event";
 const char* const HmsClient::kKuduStorageHandler = 
"org.apache.kudu.hive.KuduStorageHandler";
 
 const char* const HmsClient::kTransactionalEventListeners =
@@ -265,24 +266,27 @@ Status HmsClient::GetDatabase(const string& pattern, 
hive::Database* database) {
   return Status::OK();
 }
 
-Status HmsClient::CreateTable(const hive::Table& table) {
+Status HmsClient::CreateTable(const hive::Table& table, const 
hive::EnvironmentContext& env_ctx) {
   SCOPED_LOG_SLOW_EXECUTION(WARNING, kSlowExecutionWarningThresholdMs, "create 
HMS table");
-  HMS_RET_NOT_OK(client_.create_table(table), "failed to create Hive MetaStore 
table");
+  HMS_RET_NOT_OK(client_.create_table_with_environment_context(table, env_ctx),
+                 "failed to create Hive MetaStore table");
   return Status::OK();
 }
 
 Status HmsClient::AlterTable(const std::string& database_name,
                              const std::string& table_name,
-                             const hive::Table& table) {
+                             const hive::Table& table,
+                             const hive::EnvironmentContext& env_ctx) {
   SCOPED_LOG_SLOW_EXECUTION(WARNING, kSlowExecutionWarningThresholdMs, "alter 
HMS table");
-  HMS_RET_NOT_OK(client_.alter_table(database_name, table_name, table),
+  HMS_RET_NOT_OK(client_.alter_table_with_environment_context(database_name, 
table_name,
+                                                              table, env_ctx),
                  "failed to alter Hive MetaStore table");
   return Status::OK();
 }
 
-Status HmsClient::DropTableWithContext(const string& database_name,
-                                       const string& table_name,
-                                       const hive::EnvironmentContext& 
env_ctx) {
+Status HmsClient::DropTable(const string& database_name,
+                            const string& table_name,
+                            const hive::EnvironmentContext& env_ctx) {
   SCOPED_LOG_SLOW_EXECUTION(WARNING, kSlowExecutionWarningThresholdMs, "drop 
HMS table");
   HMS_RET_NOT_OK(client_.drop_table_with_environment_context(database_name, 
table_name,
                                                              true, env_ctx),

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/hms/hms_client.h
----------------------------------------------------------------------
diff --git a/src/kudu/hms/hms_client.h b/src/kudu/hms/hms_client.h
index 1b4d28d..0b650bc 100644
--- a/src/kudu/hms/hms_client.h
+++ b/src/kudu/hms/hms_client.h
@@ -89,6 +89,7 @@ class HmsClient {
 
   static const char* const kKuduTableIdKey;
   static const char* const kKuduMasterAddrsKey;
+  static const char* const kKuduMasterEventKey;;
   static const char* const kStorageHandlerKey;
   static const char* const kKuduStorageHandler;
 
@@ -147,17 +148,22 @@ class HmsClient {
   Status GetDatabase(const std::string& pattern, hive::Database* database) 
WARN_UNUSED_RESULT;
 
   // Creates a table in the HMS.
-  Status CreateTable(const hive::Table& table) WARN_UNUSED_RESULT;
+  Status CreateTable(const hive::Table& table,
+                     const hive::EnvironmentContext& env_ctx = 
hive::EnvironmentContext())
+    WARN_UNUSED_RESULT;
 
   // Alter a table in the HMS.
   Status AlterTable(const std::string& database_name,
                     const std::string& table_name,
-                    const hive::Table& table) WARN_UNUSED_RESULT;
+                    const hive::Table& table,
+                    const hive::EnvironmentContext& env_ctx = 
hive::EnvironmentContext())
+    WARN_UNUSED_RESULT;
 
   // Drops a Kudu table in the HMS.
-  Status DropTableWithContext(const std::string& database_name,
-                              const std::string& table_name,
-                              const hive::EnvironmentContext& env_ctx) 
WARN_UNUSED_RESULT;
+  Status DropTable(const std::string& database_name,
+                   const std::string& table_name,
+                   const hive::EnvironmentContext& env_ctx = 
hive::EnvironmentContext())
+    WARN_UNUSED_RESULT;
 
   // Retrieves an HMS table metadata.
   Status GetTable(const std::string& database_name,

http://git-wip-us.apache.org/repos/asf/kudu/blob/f54dbb89/src/kudu/integration-tests/master_hms-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/master_hms-itest.cc 
b/src/kudu/integration-tests/master_hms-itest.cc
index 14301f5..d65f669 100644
--- a/src/kudu/integration-tests/master_hms-itest.cc
+++ b/src/kudu/integration-tests/master_hms-itest.cc
@@ -19,6 +19,8 @@
 #include <map>
 #include <memory>
 #include <string>
+#include <type_traits>
+#include <utility>
 #include <vector>
 
 #include <glog/stl_logging.h>
@@ -198,8 +200,7 @@ TEST_F(MasterHmsTest, TestCreateTable) {
   ASSERT_STR_CONTAINS(s.ToString(), "☃ is not a valid object name");
 
   // Drop the HMS entry and create the table through Kudu.
-  ASSERT_OK(hms_client_->DropTableWithContext(hms_database_name, 
hms_table_name,
-                                              hive::EnvironmentContext()));
+  ASSERT_OK(hms_client_->DropTable(hms_database_name, hms_table_name));
   ASSERT_OK(CreateKuduTable(hms_database_name, hms_table_name));
   NO_FATALS(CheckTable(hms_database_name, hms_table_name));
 
@@ -259,7 +260,7 @@ TEST_F(MasterHmsTest, TestRenameTable) {
   // HmsCatalog will create a new entry when necessary.
   shared_ptr<KuduTable> table;
   ASSERT_OK(client_->OpenTable("db.a", &table));
-  ASSERT_OK(hms_client_->DropTableWithContext("db", "a", 
hive::EnvironmentContext()));
+  ASSERT_OK(hms_client_->DropTable("db", "a"));
   table_alterer.reset(client_->NewTableAlterer("db.a"));
   ASSERT_OK(table_alterer->RenameTo("db.c")->Alter());
   NO_FATALS(CheckTable("db", "c"));
@@ -282,7 +283,7 @@ TEST_F(MasterHmsTest, TestRenameTable) {
 
   // Drop the HMS table entry, then create a non-Kudu table entry in it's 
place,
   // and attempt to rename the table.
-  ASSERT_OK(hms_client_->DropTableWithContext("db", "a", 
hive::EnvironmentContext()));
+  ASSERT_OK(hms_client_->DropTable("db", "a"));
   hive::Table external_table_2;
   external_table_2.dbName = "db";
   external_table_2.tableName = "a";
@@ -313,7 +314,10 @@ TEST_F(MasterHmsTest, TestAlterTable) {
   hive::Table hms_table;
   ASSERT_OK(hms_client_->GetTable(hms_database_name, hms_table_name, 
&hms_table));
   hms_table.sd.cols.clear();
-  ASSERT_OK(hms_client_->AlterTable(hms_database_name, hms_table_name, 
hms_table));
+  // The KuduMetastorePlugin requires column alteration events to come from a 
Kudu Master.
+  hive::EnvironmentContext env_ctx;
+  env_ctx.__set_properties({ 
std::make_pair(hms::HmsClient::kKuduMasterEventKey, "true") });
+  ASSERT_OK(hms_client_->AlterTable(hms_database_name, hms_table_name, 
hms_table, env_ctx));
   hive::Table altered_table;
   ASSERT_OK(hms_client_->GetTable(hms_database_name, hms_table_name, 
&altered_table));
   ASSERT_TRUE(altered_table.sd.cols.empty());
@@ -339,8 +343,7 @@ TEST_F(MasterHmsTest, TestAlterTable) {
 
   // Drop the table from the HMS, and insert a non-Kudu table entry, then try
   // and alter the table.
-  ASSERT_OK(hms_client_->DropTableWithContext(hms_database_name, 
hms_table_name,
-                                              hive::EnvironmentContext()));
+  ASSERT_OK(hms_client_->DropTable(hms_database_name, hms_table_name));
   hms_table = hive::Table();
   hms_table.dbName = hms_database_name;
   hms_table.tableName = hms_table_name;
@@ -373,8 +376,7 @@ TEST_F(MasterHmsTest, TestDeleteTable) {
   NO_FATALS(CheckTable(hms_database_name, hms_table_name));
   shared_ptr<KuduTable> table;
   ASSERT_OK(client_->OpenTable(table_name, &table));
-  ASSERT_OK(hms_client_->DropTableWithContext(hms_database_name, 
hms_table_name,
-                                              hive::EnvironmentContext()));
+  ASSERT_OK(hms_client_->DropTable(hms_database_name, hms_table_name));
   Status s = hms_client_->GetTable(hms_database_name, hms_table_name, 
&hms_table);
   ASSERT_TRUE(s.IsNotFound()) << s.ToString();
   ASSERT_OK(client_->DeleteTable(table_name));

Reply via email to