Skip to content

Commit 8b9e24c

Browse files
committed
Revert to v1
1 parent f20a61f commit 8b9e24c

File tree

3 files changed

+24
-45
lines changed

3 files changed

+24
-45
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,18 @@ private[hive] class HiveQl(conf: ParserConf) extends SparkQl(conf) with Logging
168168
/**
169169
* Returns the HiveConf
170170
*/
171-
private[this] def hiveConf: HiveConf = HiveConfUtil.conf
171+
private[this] def hiveConf: HiveConf = {
172+
var ss = SessionState.get()
173+
// SessionState is lazy initialization, it can be null here
174+
if (ss == null) {
175+
val original = Thread.currentThread().getContextClassLoader
176+
val conf = new HiveConf(classOf[SessionState])
177+
conf.setClassLoader(original)
178+
ss = new SessionState(conf)
179+
SessionState.start(ss)
180+
}
181+
ss.getConf
182+
}
172183

173184
protected def getProperties(node: ASTNode): Seq[(String, String)] = node match {
174185
case Token("TOK_TABLEPROPLIST", list) =>

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,18 @@ private[hive] class HiveClientImpl(
134134
}
135135

136136
/** Returns the configuration for the current session. */
137-
def conf: HiveConf = HiveConfUtil.conf
137+
def conf: HiveConf = {
138+
var ss = SessionState.get()
139+
// SessionState is lazy initialization, it can be null here
140+
if (ss == null) {
141+
val original = Thread.currentThread().getContextClassLoader
142+
val conf = new HiveConf(classOf[SessionState])
143+
conf.setClassLoader(original)
144+
ss = new SessionState(conf)
145+
SessionState.start(ss)
146+
}
147+
ss.getConf
148+
}
138149

139150
override def getConf(key: String, defaultValue: String): String = {
140151
conf.get(key, defaultValue)

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

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)