Github user zhzhan commented on a diff in the pull request:
https://github.com/apache/spark/pull/2241#discussion_r18969029
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala ---
@@ -288,23 +290,26 @@ class HiveContext(sc: SparkContext) extends
SQLContext(sc) {
val cmd_trimmed: String = cmd.trim()
val tokens: Array[String] = cmd_trimmed.split("\\s+")
val cmd_1: String = cmd_trimmed.substring(tokens(0).length()).trim()
- val proc: CommandProcessor = CommandProcessorFactory.get(tokens(0),
hiveconf)
+ val proc: CommandProcessor =
HiveShim.getCommandProcessor(Array(tokens(0)), hiveconf)
proc match {
case driver: Driver =>
- driver.init()
-
- val results = new JArrayList[String]
+ val results = HiveShim.createDriverResultsArray
val response: CommandProcessorResponse = driver.run(cmd)
// Throw an exception if there is an error in query processing.
if (response.getResponseCode != 0) {
- driver.destroy()
+ driver.close()
throw new QueryExecutionException(response.getErrorMessage)
}
driver.setMaxRows(maxRows)
driver.getResults(results)
- driver.destroy()
- results
+ driver.close()
+ results.map { r =>
+ r match {
+ case s: String => s
+ case o => o.toString
--- End diff --
@scwf Thanks for the review. The reason I did this is that in hive testing
code, I actually didn't find a case which the result value is not
Array[String], and there the results is even initialized as Array[String]. For
for the safety reason, I will change the code to process Array[Arrray[Object]].
This patch is independent with thrift server, but the thrift server patch
should be verified after this one going to upstream, mainly due to pom file
change.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]