This is an automated email from the ASF dual-hosted git repository.
xushiyan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new bb42c4b96f0 [HUDI-7097] Fix instantiation of Hms Uri with HiveSync
tool (#10099)
bb42c4b96f0 is described below
commit bb42c4b96f076a7b8b78630c5186bc147b428d67
Author: Sivabalan Narayanan <[email protected]>
AuthorDate: Thu Nov 23 18:33:32 2023 -0800
[HUDI-7097] Fix instantiation of Hms Uri with HiveSync tool (#10099)
---
.../java/org/apache/hudi/hive/HiveSyncTool.java | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git
a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveSyncTool.java
b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveSyncTool.java
index 5150e0debbe..9d44bbdc07e 100644
---
a/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveSyncTool.java
+++
b/hudi-sync/hudi-hive-sync/src/main/java/org/apache/hudi/hive/HiveSyncTool.java
@@ -46,7 +46,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
-import static org.apache.hudi.common.util.StringUtils.isNullOrEmpty;
import static org.apache.hudi.common.util.StringUtils.nonEmpty;
import static
org.apache.hudi.hadoop.utils.HoodieInputFormatUtils.getInputFormatClassName;
import static
org.apache.hudi.hadoop.utils.HoodieInputFormatUtils.getOutputFormatClassName;
@@ -103,15 +102,19 @@ public class HiveSyncTool extends HoodieSyncTool
implements AutoCloseable {
public HiveSyncTool(Properties props, Configuration hadoopConf) {
super(props, hadoopConf);
- String metastoreUris = props.getProperty(METASTORE_URIS.key());
- // Give precedence to HiveConf.ConfVars.METASTOREURIS if it is set.
- // Else if user has provided HiveSyncConfigHolder.METASTORE_URIS, then set
that in hadoop conf.
- if (isNullOrEmpty(hadoopConf.get(HiveConf.ConfVars.METASTOREURIS.varname))
&& nonEmpty(metastoreUris)) {
- LOG.info(String.format("Setting %s = %s",
HiveConf.ConfVars.METASTOREURIS.varname, metastoreUris));
- hadoopConf.set(HiveConf.ConfVars.METASTOREURIS.varname, metastoreUris);
+ String configuredMetastoreUris = props.getProperty(METASTORE_URIS.key());
+
+ final Configuration hadoopConfForSync; // the configuration to use for
this instance of the sync tool
+ if (nonEmpty(configuredMetastoreUris)) {
+ // if metastore uri is configured, we can create a new configuration
with the value set
+ hadoopConfForSync = new Configuration(hadoopConf);
+ hadoopConfForSync.set(HiveConf.ConfVars.METASTOREURIS.varname,
configuredMetastoreUris);
+ } else {
+ // if the user did not provide any URIs, then we can use the provided
configuration
+ hadoopConfForSync = hadoopConf;
}
- HiveSyncConfig config = new HiveSyncConfig(props, hadoopConf);
- this.config = config;
+
+ this.config = new HiveSyncConfig(props, hadoopConfForSync);
this.databaseName = config.getStringOrDefault(META_SYNC_DATABASE_NAME);
this.tableName = config.getStringOrDefault(META_SYNC_TABLE_NAME);
initSyncClient(config);