You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by ga...@apache.org on 2023/09/11 06:43:05 UTC

[seatunnel] branch dev updated: [Hotfix][Connector-V2][Hive] fix the bug that hive-site.xml can not be injected in HiveConf (#5261)

This is an automated email from the ASF dual-hosted git repository.

gaojun2048 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 04ce22ac1e [Hotfix][Connector-V2][Hive] fix the bug that hive-site.xml can not be injected in HiveConf (#5261)
04ce22ac1e is described below

commit 04ce22ac1eb34f1bb976764e97bed5f15edaed5a
Author: Volodymyr <vo...@gmail.com>
AuthorDate: Mon Sep 11 14:42:59 2023 +0800

    [Hotfix][Connector-V2][Hive] fix the bug that hive-site.xml can not be injected in HiveConf (#5261)
---
 .../seatunnel/hive/utils/HiveMetaStoreProxy.java        | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java b/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java
index f6ba5cfb12..788fe38dc1 100644
--- a/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java
+++ b/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java
@@ -35,6 +35,8 @@ import org.apache.thrift.TException;
 import lombok.NonNull;
 import lombok.extern.slf4j.Slf4j;
 
+import java.io.File;
+import java.net.MalformedURLException;
 import java.util.List;
 import java.util.Objects;
 
@@ -54,10 +56,11 @@ public class HiveMetaStoreProxy {
             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 =
@@ -67,6 +70,14 @@ public class HiveMetaStoreProxy {
                             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);
         }
     }