Skip to content

Commit 804949d

Browse files
yhuaimarmbrus
authored andcommitted
[SQL] Set sessionState in QueryExecution.
This PR sets the SessionState in HiveContext's QueryExecution. So, we can make sure that SessionState.get can return the SessionState every time. Author: Yin Huai <[email protected]> Closes apache#4445 from yhuai/setSessionState and squashes the following commits: 769c9f1 [Yin Huai] Remove unused import. 439f329 [Yin Huai] Try again. 427a0c9 [Yin Huai] Set SessionState everytime when we create a QueryExecution in HiveContext. a3b7793 [Yin Huai] Set sessionState when dealing with CreateTableAsSelect.
1 parent 75fdccc commit 804949d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
424424
/** Extends QueryExecution with hive specific features. */
425425
protected[sql] class QueryExecution(logicalPlan: LogicalPlan)
426426
extends super.QueryExecution(logicalPlan) {
427+
// Like what we do in runHive, makes sure the session represented by the
428+
// `sessionState` field is activated.
429+
if (SessionState.get() != sessionState) {
430+
SessionState.start(sessionState)
431+
}
427432

428433
/**
429434
* Returns the result as a hive compatible sequence of strings. For native commands, the

0 commit comments

Comments
 (0)