aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Armbrust <michael@databricks.com>2014-10-02 19:32:21 -0700
committerMichael Armbrust <michael@databricks.com>2014-10-02 19:32:21 -0700
commit7de4e50a01e90bcf88e0b721b2b15a5162373d56 (patch)
tree8ac6a77d06423bcd830558aff8d5c31325e2201f
parent42d5077fd3f2c37d1cd23f4c81aa89286a74cb40 (diff)
downloadspark-7de4e50a01e90bcf88e0b721b2b15a5162373d56.tar.gz
spark-7de4e50a01e90bcf88e0b721b2b15a5162373d56.tar.bz2
spark-7de4e50a01e90bcf88e0b721b2b15a5162373d56.zip
[SQL] Initilize session state before creating CommandProcessor
With the old ordering it was possible for commands in the HiveDriver to NPE due to the lack of configuration in the threadlocal session state. Author: Michael Armbrust <michael@databricks.com> Closes #2635 from marmbrus/initOrder and squashes the following commits: 9749850 [Michael Armbrust] Initilize session state before creating CommandProcessor
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
index fdb56901f9..8bcc098bbb 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala
@@ -281,13 +281,14 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
*/
protected def runHive(cmd: String, maxRows: Int = 1000): Seq[String] = {
try {
+ // Session state must be initilized before the CommandProcessor is created .
+ SessionState.start(sessionState)
+
val cmd_trimmed: String = cmd.trim()
val tokens: Array[String] = cmd_trimmed.split("\\s+")
val cmd_1: String = cmd_trimmed.substring(tokens(0).length()).trim()
val proc: CommandProcessor = CommandProcessorFactory.get(tokens(0), hiveconf)
- SessionState.start(sessionState)
-
proc match {
case driver: Driver =>
driver.init()