This is an automated email from the ASF dual-hosted git repository.
suvasude pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-gobblin.git
The following commit(s) were added to refs/heads/master by this push:
new 00eb1f7 [GOBBLIN-986] persist the existing property of iceberg
00eb1f7 is described below
commit 00eb1f79dbdd4bc562a76867db0c47928fa4aeaa
Author: Zihan Li <[email protected]>
AuthorDate: Mon Dec 2 13:55:58 2019 -0800
[GOBBLIN-986] persist the existing property of iceberg
Closes #2831 from ZihanLi58/GOBBLIN-986
---
.../gobblin/hive/metastore/HiveMetaStoreBasedRegister.java | 13 +++++++------
.../apache/gobblin/hive/metastore/HiveMetaStoreUtils.java | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
index 6dc466b..a25efdd 100644
---
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
+++
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
@@ -669,14 +669,15 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
@Override
public void alterTable(HiveTable table) throws IOException {
try (AutoReturnableObject<IMetaStoreClient> client =
this.clientPool.getClient()) {
- boolean tableExists;
- try (Timer.Context context =
this.metricContext.timer(TABLE_EXISTS).time()) {
- tableExists = client.get().tableExists(table.getDbName(),
table.getTableName());
- }
- if (!tableExists) {
- throw new IOException("Table " + table.getTableName() + " in db " +
table.getDbName() + " does not exist");
+ Table existingTable;
+ //During alter table we need to persist the existing property of iceberg
in HMS
+ try (Timer.Context context =
this.metricContext.timer(GET_HIVE_TABLE).time()) {
+ existingTable = client.get().getTable(table.getDbName(),
table.getTableName());
+ } catch (Exception e){
+ throw new IOException("Cannot get table " + table.getTableName() + "
in db " + table.getDbName(), e);
}
try (Timer.Context context =
this.metricContext.timer(ALTER_TABLE).time()) {
+
table.getProps().addAllIfNotExist(HiveMetaStoreUtils.getTableProps(existingTable));
client.get().alter_table(table.getDbName(), table.getTableName(),
getTableWithCreateTimeNow(HiveMetaStoreUtils.getTable(table)));
}
diff --git
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java
index bb6a8b8..976c9e3 100644
---
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java
+++
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreUtils.java
@@ -253,7 +253,7 @@ public class HiveMetaStoreUtils {
return si;
}
- private static State getTableProps(Table table) {
+ public static State getTableProps(Table table) {
State tableProps = new State();
for (Map.Entry<String, String> entry : table.getParameters().entrySet()) {
tableProps.setProp(entry.getKey(), entry.getValue());