Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
keep hive conf
  • Loading branch information
Dong Wang committed Jun 5, 2015
commit 184ec353c86e52211f13e3fdbbb2c2651a955d6c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import org.apache.commons.logging.Log
import org.apache.hadoop.hive.conf.HiveConf
import org.apache.hadoop.hive.conf.HiveConf.ConfVars
import org.apache.hadoop.hive.metastore.api.FieldSchema
import org.apache.hadoop.hive.ql.metadata.Hive
import org.apache.hadoop.hive.ql.metadata.HiveException
import org.apache.hadoop.hive.ql.session.SessionState
import org.apache.hadoop.hive.shims.ShimLoader
import org.apache.hadoop.security.UserGroupInformation
Expand Down Expand Up @@ -149,8 +151,9 @@ private[hive] class SparkExecuteStatementOperation(
runInternal()
} else {
val parentSessionState = SessionState.get()
val hiveConf = new HiveConf(getParentSession().getHiveConf())
val hiveConf = getConfigForOperation()
val sparkServiceUGI = ShimLoader.getHadoopShims.getUGIForConf(hiveConf)
val sessionHive = getCurrentHive()

// Runnable impl to call runInternal asynchronously,
// from a different thread
Expand All @@ -161,6 +164,7 @@ private[hive] class SparkExecuteStatementOperation(
override def run(): Object = {

// User information is part of the metastore client member in Hive
Hive.set(sessionHive)
SessionState.setCurrentSessionState(parentSessionState)
try {
runInternal()
Expand Down Expand Up @@ -270,4 +274,42 @@ private[hive] class SparkExecuteStatementOperation(
}
}
}

/**
* If there are query specific settings to overlay, then create a copy of config
* There are two cases we need to clone the session config that's being passed to hive driver
* 1. Async query -
* If the client changes a config setting, that shouldn't reflect in the execution already underway
* 2. confOverlay -
* The query specific settings should only be applied to the query config and not session
* @return new configuration
* @throws HiveSQLException
*/
private def getConfigForOperation(): HiveConf = {
var sqlOperationConf = getParentSession().getHiveConf()
if (!getConfOverlay().isEmpty() || runInBackground) {
// clone the partent session config for this query
sqlOperationConf = new HiveConf(sqlOperationConf)

// apply overlay query specific settings, if any
getConfOverlay().foreach { case (k, v) =>
try {
sqlOperationConf.verifyAndSet(k, v)
} catch {
case e: IllegalArgumentException =>
throw new HiveSQLException("Error applying statement specific settings", e)
}
}
}
return sqlOperationConf
}

private def getCurrentHive(): Hive = {
try {
return Hive.get()
} catch {
case e: HiveException =>
throw new HiveSQLException("Failed to get current Hive object", e);
}
}
}