Skip to content

Commit

Permalink
[Hotfix][Connector-V2][Hive] fix the bug that hive-site.xml can not b…
Browse files Browse the repository at this point in the history
…e injected in HiveConf (#5261)
  • Loading branch information
VolodymyrDuke authored Sep 11, 2023
1 parent 23d79b0 commit 04ce22a
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Objects;

Expand All @@ -54,10 +56,11 @@ private HiveMetaStoreProxy(Config config) {
Configuration configuration = new Configuration();
FileSystemUtils.doKerberosAuthentication(configuration, principal, keytabPath);
}
if (config.hasPath(HiveConfig.HIVE_SITE_PATH.key())) {
hiveConf.addResource(config.getString(HiveConfig.HIVE_SITE_PATH.key()));
}
try {
if (config.hasPath(HiveConfig.HIVE_SITE_PATH.key())) {
String hiveSitePath = config.getString(HiveConfig.HIVE_SITE_PATH.key());
hiveConf.addResource(new File(hiveSitePath).toURI().toURL());
}
hiveMetaStoreClient = new HiveMetaStoreClient(hiveConf);
} catch (MetaException e) {
String errorMsg =
Expand All @@ -67,6 +70,14 @@ private HiveMetaStoreProxy(Config config) {
metastoreUri);
throw new HiveConnectorException(
HiveConnectorErrorCode.INITIALIZE_HIVE_METASTORE_CLIENT_FAILED, errorMsg, e);
} catch (MalformedURLException e) {
String errorMsg =
String.format(
"Using this hive uris [%s], hive conf [%s] to initialize "
+ "hive metastore client instance failed",
metastoreUri, config.getString(HiveConfig.HIVE_SITE_PATH.key()));
throw new HiveConnectorException(
HiveConnectorErrorCode.INITIALIZE_HIVE_METASTORE_CLIENT_FAILED, errorMsg, e);
}
}

Expand Down

0 comments on commit 04ce22a

Please sign in to comment.