Skip to content

Commit 68656a1

Browse files
yhuaizzcclp
authored andcommitted
[SPARK-17245][SQL][BRANCH-1.6] Do not rely on Hive's session state to retrieve HiveConf
## What changes were proposed in this pull request? Right now, we rely on Hive's `SessionState.get()` to retrieve the HiveConf used by ClientWrapper. However, this conf is actually the HiveConf set with the `state`. There is a small chance that we are trying to use the Hive client in a new thread while the global client has not been created yet. In this case, `SessionState.get()` will return a `null`, which causes a NPE when we call `SessionState.get(). getConf `. Since the conf that we want is actually the conf we set to `state`. I am changing the code to just call `state.getConf` (this is also what Spark 2.0 does). ## How was this patch tested? I have not figured out a good way to reproduce this. Author: Yin Huai <yhuai@databricks.com> Closes apache#14816 from yhuai/SPARK-17245. (cherry picked from commit 047bc3f)
1 parent 3a1e6ab commit 68656a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/client/ClientWrapper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private[hive] class ClientWrapper(
213213
}
214214

215215
/** Returns the configuration for the current session. */
216-
def conf: HiveConf = SessionState.get().getConf
216+
def conf: HiveConf = state.getConf
217217

218218
override def getConf(key: String, defaultValue: String): String = {
219219
conf.get(key, defaultValue)

0 commit comments

Comments
 (0)