Skip to content
Snippets Groups Projects
Commit 920cb5fe authored by Cheng Hao's avatar Cheng Hao Committed by Reynold Xin
Browse files

[SPARK-15730][SQL] Respect the --hiveconf in the spark-sql command line

## What changes were proposed in this pull request?
This PR makes spark-sql (backed by SparkSQLCLIDriver) respects confs set by hiveconf, which is what we do in previous versions. The change is that when we start SparkSQLCLIDriver, we explicitly set confs set through --hiveconf to SQLContext's conf (basically treating those confs as a SparkSQL conf).

## How was this patch tested?
A new test in CliSuite.

Closes #13542

Author: Cheng Hao <hao.cheng@intel.com>
Author: Yin Huai <yhuai@databricks.com>

Closes #14058 from yhuai/hiveConfThriftServer.
parent 5b7a1770
No related branches found
No related tags found
No related merge requests found
......@@ -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))
}
......
......@@ -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"
)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment