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

 ##########
 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:
   we need hive-site.xml in sparkContext.hadoopConfiguration not just the new 
fresh hadoopConf

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to