Skip to content

Commit

Permalink
[HUDI-7097] Fix instantiation of Hms Uri with HiveSync tool (#10099)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivabalan authored Nov 24, 2023
1 parent bcb974b commit bb42c4b
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bb42c4b

Please sign in to comment.