This is an automated email from the ASF dual-hosted git repository.
hutran 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 b0d1307 [GOBBLIN-705] create method to merging tblProps from existing
hive meta table
b0d1307 is described below
commit b0d130757669a5fed7c368d44f23f8a9c0d3ed4a
Author: autumnust <[email protected]>
AuthorDate: Thu Mar 21 12:49:47 2019 -0700
[GOBBLIN-705] create method to merging tblProps from existing hive meta
table
Closes #2575 from autumnust/UnionTblProps
---
.../hive/metastore/HiveMetaStoreBasedRegister.java | 47 ++++++++++++++++------
1 file changed, 35 insertions(+), 12 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 0ee5445..b676737 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
@@ -165,13 +165,6 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
}
- @Override
- public boolean createDbIfNotExists(String dbName) throws IOException {
- try (AutoReturnableObject<IMetaStoreClient> client =
this.clientPool.getClient()) {
- return createDbIfNotExists(client.get(), dbName);
- }
- }
-
/**
* If table existed on Hive side will return false;
* Or will create the table thru. RPC and return retVal from remote
MetaStore.
@@ -200,7 +193,7 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
if (needToUpdateTable(existingTable, spec.getTable())) {
try (Timer.Context context =
this.metricContext.timer(ALTER_TABLE).time()) {
- client.alter_table(dbName, tableName,
getTableWithCreateTime(table, existingTable));
+ client.alter_table(dbName, tableName,
getNewTblByMergingExistingTblProps(table, existingTable));
}
log.info(String.format("updated Hive table %s in db %s", tableName,
dbName));
}
@@ -281,6 +274,20 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
}
+ /**
+ * @deprecated Use {@link #createDbIfNotExists(IMetaStoreClient, String)}
directly.
+ */
+ @Deprecated
+ public boolean createDbIfNotExists(String dbName) throws IOException {
+ try (AutoReturnableObject<IMetaStoreClient> client =
this.clientPool.getClient()) {
+ return createDbIfNotExists(client.get(), dbName);
+ }
+ }
+
+ /**
+ * @deprecated Please use {@link #createOrAlterTable(IMetaStoreClient,
Table, HiveSpec)} instead.
+ */
+ @Deprecated
@Override
public boolean createTableIfNotExists(HiveTable table) throws IOException {
try (AutoReturnableObject<IMetaStoreClient> client =
this.clientPool.getClient();
@@ -289,6 +296,10 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
}
+ /**
+ * @deprecated Use {@link #addOrAlterPartition} instead.
+ */
+ @Deprecated
@Override
public boolean addPartitionIfNotExists(HiveTable table, HivePartition
partition) throws IOException {
try (AutoReturnableObject<IMetaStoreClient> client =
this.clientPool.getClient();
@@ -312,6 +323,10 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
}
+ @Deprecated
+ /**
+ * @deprecated Please use {@link #createOrAlterTable(IMetaStoreClient,
Table, HiveSpec)} instead.
+ */
private boolean createTableIfNotExists(IMetaStoreClient client, Table table,
HiveTable hiveTable) throws IOException {
String dbName = table.getDbName();
String tableName = table.getTableName();
@@ -357,10 +372,6 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
}
}
-
-
-
-
@Override
public boolean existsTable(String dbName, String tableName) throws
IOException {
if (this.optimizedChecks &&
this.tableAndDbExistenceCache.getIfPresent(dbName + ":" + tableName ) != null )
{
@@ -617,4 +628,16 @@ public class HiveMetaStoreBasedRegister extends
HiveRegister {
return actualtable;
}
+
+ /**
+ * Used to merge properties from existingTable to newTable.
+ * e.g. New table will inherit creation time from existing table.
+ *
+ * This method is extensible for customized logic in merging table
properties.
+ * @param newTable
+ * @param existingTable
+ */
+ protected Table getNewTblByMergingExistingTblProps(Table newTable, HiveTable
existingTable) {
+ return getTableWithCreateTime(newTable, existingTable);
+ }
}