You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/20 10:11:13 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #27969: [SPARK-31170][SQL][hive-1.2] Spark SQL Cli should respect hive-site.xml and spark.sql.warehouse.dir

yaooqinn commented on a change in pull request #27969: [SPARK-31170][SQL][hive-1.2] Spark SQL Cli should respect hive-site.xml and spark.sql.warehouse.dir
URL: https://github.com/apache/spark/pull/27969#discussion_r395540634
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/internal/SharedState.scala
 ##########
 @@ -258,4 +223,47 @@ object SharedState extends Logging {
         throw new IllegalArgumentException(s"Error while instantiating '$className':", e)
     }
   }
+
+  /**
+   * Load hive-site.xml into hadoopConf and determine the warehouse path we want to use, based on
+   * the config from both hive and Spark SQL. Finally set the warehouse config value to sparkConf.
+   */
+  def loadHiveConfFile(
+      sparkConf: SparkConf,
+      hadoopConf: Configuration): Boolean = {
+    val hiveWarehouseKey = "hive.metastore.warehouse.dir"
+    val configFile = Utils.getContextOrSparkClassLoader.getResource("hive-site.xml")
+    if (configFile != null) {
+      logInfo(s"loading hive config file: $configFile")
+      // this call actually will override existing configurations from hive-site.xml
+      hadoopConf.addResource(configFile)
 
 Review comment:
   ```java
    /**
      * Add a configuration resource. 
      * 
      * The properties of this resource will override properties of previously 
      * added resources, unless they were marked <a href="#Final">final</a>. 
      * 
      * @param url url of the resource to be added, the local filesystem is 
      *            examined directly to find the resource, without referring to 
      *            the classpath.
      */
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org