kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject [kudu] branch master updated: hms: synchronize column comments to the HMS
Date Tue, 21 May 2019 16:47:31 GMT
This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 722678d  hms: synchronize column comments to the HMS
722678d is described below

commit 722678db690084c511afff19c643a549857c04fe
Author: Grant Henke <granthenke@apache.org>
AuthorDate: Mon May 20 17:06:02 2019 -0500

    hms: synchronize column comments to the HMS
    
    This patch ensures column comments are
    synchronized to the HMS when a table is created
    or altered.
    
    Change-Id: I12da391ea74e153483b6657e7028aa6784ac41b3
    Reviewed-on: http://gerrit.cloudera.org:8080/13381
    Reviewed-by: Hao Hao <hao.hao@cloudera.com>
    Tested-by: Grant Henke <granthenke@apache.org>
---
 src/kudu/hms/hms_catalog.cc                    | 1 +
 src/kudu/integration-tests/hms_itest-base.cc   | 4 +++-
 src/kudu/integration-tests/master_hms-itest.cc | 8 ++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/kudu/hms/hms_catalog.cc b/src/kudu/hms/hms_catalog.cc
index ac211e8..fd564ea 100644
--- a/src/kudu/hms/hms_catalog.cc
+++ b/src/kudu/hms/hms_catalog.cc
@@ -313,6 +313,7 @@ hive::FieldSchema column_to_field(const ColumnSchema& column) {
   hive::FieldSchema field;
   field.name = column.name();
   field.type = column_to_field_type(column);
+  field.comment = column.comment();
   return field;
 }
 
diff --git a/src/kudu/integration-tests/hms_itest-base.cc b/src/kudu/integration-tests/hms_itest-base.cc
index 64a635b..4a29744 100644
--- a/src/kudu/integration-tests/hms_itest-base.cc
+++ b/src/kudu/integration-tests/hms_itest-base.cc
@@ -78,7 +78,8 @@ Status HmsITestBase::CreateKuduTable(const string& database_name,
                                      MonoDelta timeout) {
   // Get coverage of all column types.
   KuduSchemaBuilder b;
-  b.AddColumn("key")->Type(KuduColumnSchema::INT32)->NotNull()->PrimaryKey();
+  b.AddColumn("key")->Type(KuduColumnSchema::INT32)->NotNull()
+                    ->PrimaryKey()->Comment("The Primary Key");
   b.AddColumn("int8_val")->Type(KuduColumnSchema::INT8);
   b.AddColumn("int16_val")->Type(KuduColumnSchema::INT16);
   b.AddColumn("int32_val")->Type(KuduColumnSchema::INT32);
@@ -159,6 +160,7 @@ void HmsITestBase::CheckTable(const string& database_name,
   ASSERT_EQ(schema.num_columns(), hms_table.sd.cols.size());
   for (int idx = 0; idx < schema.num_columns(); idx++) {
     ASSERT_EQ(schema.Column(idx).name(), hms_table.sd.cols[idx].name);
+    ASSERT_EQ(schema.Column(idx).comment(), hms_table.sd.cols[idx].comment);
   }
   ASSERT_EQ(table->id(), hms_table.parameters[hms::HmsClient::kKuduTableIdKey]);
   ASSERT_EQ(HostPort::ToCommaSeparatedString(cluster_->master_rpc_addrs()),
diff --git a/src/kudu/integration-tests/master_hms-itest.cc b/src/kudu/integration-tests/master_hms-itest.cc
index 0574eba..0e680b4 100644
--- a/src/kudu/integration-tests/master_hms-itest.cc
+++ b/src/kudu/integration-tests/master_hms-itest.cc
@@ -25,6 +25,7 @@
 #include <gtest/gtest.h>
 
 #include "kudu/client/client.h"
+#include "kudu/client/schema.h"
 #include "kudu/client/shared_ptr.h"
 #include "kudu/common/common.pb.h"
 #include "kudu/common/table_util.h"
@@ -240,6 +241,13 @@ TEST_F(MasterHmsTest, TestAlterTable) {
   ASSERT_OK(table_alterer->DropColumn("int8_val")->Alter());
   NO_FATALS(CheckTable("default", "a", /*user=*/ none));
 
+  // Alter a column comment in Kudu. This should be reflected in the HMS.
+  unique_ptr<KuduTableAlterer> comment_alterer(client_->NewTableAlterer("default.a"));
+  comment_alterer->AlterColumn("key")->Comment("");
+  comment_alterer->AlterColumn("int16_val")->Comment("A new comment");
+  ASSERT_OK(comment_alterer->Alter());
+  NO_FATALS(CheckTable("default", "a", /*user=*/ none));
+
   // Shutdown the HMS and try to alter the table.
   ASSERT_OK(StopHms());
   table_alterer.reset(client_->NewTableAlterer("default.a")->DropColumn("int16_val"));


Mime
View raw message