aboutsummaryrefslogtreecommitdiff
path: root/sql/hive-thriftserver
diff options
context:
space:
mode:
Diffstat (limited to 'sql/hive-thriftserver')
-rw-r--r--sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala8
-rw-r--r--sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala11
2 files changed, 19 insertions, 0 deletions
diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
index 7389e18aef..5dafec1c30 100644
--- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
+++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
@@ -156,6 +156,14 @@ private[hive] object SparkSQLCLIDriver extends Logging {
// Execute -i init files (always in silent mode)
cli.processInitFiles(sessionState)
+ // Respect the configurations set by --hiveconf from the command line
+ // (based on Hive's CliDriver).
+ val it = sessionState.getOverriddenConfigurations.entrySet().iterator()
+ while (it.hasNext) {
+ val kv = it.next()
+ SparkSQLEnv.sqlContext.setConf(kv.getKey, kv.getValue)
+ }
+
if (sessionState.execString != null) {
System.exit(cli.processLine(sessionState.execString))
}
diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
index 75535cad1b..d3cec11bd7 100644
--- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
+++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
@@ -91,6 +91,8 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
| --hiveconf ${ConfVars.METASTORECONNECTURLKEY}=$jdbcUrl
| --hiveconf ${ConfVars.METASTOREWAREHOUSE}=$warehousePath
| --hiveconf ${ConfVars.SCRATCHDIR}=$scratchDirPath
+ | --hiveconf conf1=conftest
+ | --hiveconf conf2=1
""".stripMargin.split("\\s+").toSeq ++ extraArgs
}
@@ -272,4 +274,13 @@ class CliSuite extends SparkFunSuite with BeforeAndAfterAll with Logging {
s"LIST FILE $dataFilePath;" -> "small_kv.txt"
)
}
+
+ test("apply hiveconf from cli command") {
+ runCliWithin(2.minute)(
+ "SET conf1;" -> "conftest",
+ "SET conf2;" -> "1",
+ "SET conf3=${hiveconf:conf1};" -> "conftest",
+ "SET conf3;" -> "conftest"
+ )
+ }
}