Alibaba-HZY commented on code in PR #831:
URL: https://github.com/apache/incubator-paimon/pull/831#discussion_r1157377577


##########
paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java:
##########
@@ -521,9 +528,89 @@ static IMetaStoreClient createClient(HiveConf hiveConf, 
String clientClassName)
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-        return StringUtils.isNullOrWhitespaceOnly(
-                        hiveConf.get(HiveConf.ConfVars.METASTOREURIS.varname))
+        return 
isNullOrWhitespaceOnly(hiveConf.get(HiveConf.ConfVars.METASTOREURIS.varname))
                 ? client
                 : HiveMetaStoreClient.newSynchronizedClient(client);
     }
+
+    public static HiveConf createHiveConf(
+            @Nullable String hiveConfDir, @Nullable String hadoopConfDir) {
+        // create HiveConf from hadoop configuration with hadoop conf 
directory configured.
+        Configuration hadoopConf = null;
+        if (!isNullOrWhitespaceOnly(hadoopConfDir)) {
+            hadoopConf = getHadoopConfiguration(hadoopConfDir);
+            if (hadoopConf == null) {
+                String possiableUsedConfFiles =
+                        "core-site.xml | hdfs-site.xml | yarn-site.xml | 
mapred-site.xml";
+                throw new RuntimeException(
+                        "Failed to load the hadoop conf from specified path:" 
+ hadoopConfDir,
+                        new FileNotFoundException(
+                                "Please check the path none of the conf files 
("
+                                        + possiableUsedConfFiles
+                                        + ") exist in the folder."));
+            }
+        }
+        if (hadoopConf == null) {
+            hadoopConf = new Configuration();
+        }
+        // ignore all the static conf file URLs that HiveConf may have set
+        HiveConf.setHiveSiteLocation(null);
+        HiveConf.setLoadMetastoreConfig(false);
+        HiveConf.setLoadHiveServer2Config(false);
+        HiveConf hiveConf = new HiveConf(hadoopConf, HiveConf.class);
+
+        LOG.info("Setting hive conf dir as {}", hiveConfDir);
+
+        if (hiveConfDir != null) {
+            org.apache.hadoop.fs.Path hiveSite =
+                    new org.apache.hadoop.fs.Path(hiveConfDir, HIVE_SITE_FILE);
+            if (!hiveSite.toUri().isAbsolute()) {
+                // treat relative URI as local file to be compatible with 
previous behavior

Review Comment:
   this comment is not accurate.before during the initialization of the 
hiveconf class, the hive-site.xml file under System.getenv("HIVE_HOME ") 
/hive-conf is loaded. now, only the hive-site.xml file configured by the 
hive-conf-dir is loaded



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to