wangyum commented on a change in pull request #30536:
URL: https://github.com/apache/spark/pull/30536#discussion_r532311234
##########
File path:
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLSessionManager.scala
##########
@@ -52,24 +53,35 @@ private[hive] class SparkSQLSessionManager(hiveServer:
HiveServer2, sqlContext:
val sessionHandle =
super.openSession(protocol, username, passwd, ipAddress, sessionConf,
withImpersonation,
delegationToken)
- val session = super.getSession(sessionHandle)
- HiveThriftServer2.eventManager.onSessionCreated(
- session.getIpAddress, sessionHandle.getSessionId.toString,
session.getUsername)
- val ctx = if (sqlContext.conf.hiveThriftServerSingleSession) {
- sqlContext
- } else {
- sqlContext.newSession()
+ try {
+ val session = super.getSession(sessionHandle)
+ HiveThriftServer2.eventManager.onSessionCreated(
+ session.getIpAddress, sessionHandle.getSessionId.toString,
session.getUsername)
+ val ctx = if (sqlContext.conf.hiveThriftServerSingleSession) {
+ sqlContext
+ } else {
+ sqlContext.newSession()
+ }
+ ctx.setConf(HiveUtils.FAKE_HIVE_VERSION.key,
HiveUtils.builtinHiveVersion)
+ ctx.setConf(SQLConf.DATETIME_JAVA8API_ENABLED, true)
+ val hiveSessionState = session.getSessionState
+ setConfMap(ctx, hiveSessionState.getOverriddenConfigurations)
+ setConfMap(ctx, hiveSessionState.getHiveVariables)
+ if (sessionConf != null && sessionConf.containsKey("use:database")) {
+ ctx.sql(s"use ${sessionConf.get("use:database")}")
+ }
+ sparkSqlOperationManager.sessionToContexts.put(sessionHandle, ctx)
+ sessionHandle
+ } catch {
+ case e: Exception =>
+ try {
+ closeSession(sessionHandle)
+ } catch {
+ case t: Throwable =>
+ logWarning("Error closing session", t)
+ }
+ throw new HiveSQLException("Failed to open new session: " + e, e)
Review comment:
The logic same to
https://github.com/apache/spark/blob/008a2ad1f836ff04fafd51a9c94c355ef35f1692/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/session/SessionManager.java#L273-L282
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]