File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
sql/hive-thriftserver/src
main/scala/org/apache/spark/sql/hive/thriftserver
test/scala/org/apache/spark/sql/hive/thriftserver Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,9 @@ private[hive] object SparkSQLCLIDriver extends Logging {
156156 // Execute -i init files (always in silent mode)
157157 cli.processInitFiles(sessionState)
158158
159+ // Respect the configurations from the command line and .hiverc for backward-compatible
160+ SparkSQLEnv .applyOverridedConf(sessionState)
161+
159162 if (sessionState.execString != null ) {
160163 System .exit(cli.processLine(sessionState.execString))
161164 }
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ package org.apache.spark.sql.hive.thriftserver
1919
2020import java .io .PrintStream
2121
22- import scala . collection . JavaConverters . _
22+ import org . apache . hadoop . hive . ql . session . SessionState
2323
2424import org .apache .spark .{SparkConf , SparkContext }
2525import org .apache .spark .internal .Logging
@@ -66,6 +66,14 @@ private[hive] object SparkSQLEnv extends Logging {
6666 }
6767 }
6868
69+ def applyOverridedConf (ss : SessionState ): Unit = {
70+ val it = ss.getOverriddenConfigurations.entrySet().iterator()
71+ while (it.hasNext) {
72+ val kv = it.next()
73+ SparkSQLEnv .sqlContext.setConf(kv.getKey, kv.getValue)
74+ }
75+ }
76+
6977 /** Cleans up and shuts down the Spark SQL environments. */
7078 def stop () {
7179 logDebug(" Shutting down Spark SQL Environment" )
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
9191 | --hiveconf ${ConfVars .METASTORECONNECTURLKEY }= $jdbcUrl
9292 | --hiveconf ${ConfVars .METASTOREWAREHOUSE }= $warehousePath
9393 | --hiveconf ${ConfVars .SCRATCHDIR }= $scratchDirPath
94+ | --hiveconf conf1=conftest
95+ | --hiveconf conf2=1
9496 """ .stripMargin.split(" \\ s+" ).toSeq ++ extraArgs
9597 }
9698
@@ -272,4 +274,13 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
272274 s " LIST FILE $dataFilePath; " -> " small_kv.txt"
273275 )
274276 }
277+
278+ test(" apply hiveconf from cli command" ) {
279+ runCliWithin(2 .minute)(
280+ s " SET conf1; " -> " conftest" ,
281+ s " SET conf2; " -> " 1" ,
282+ // bypassed by SparkSQLCLIDriver
283+ s " SET ${ConfVars .METASTORECONNECTURLKEY }; " -> " undefined"
284+ )
285+ }
275286}
You can’t perform that action at this time.
0 commit comments