Skip to content
Snippets Groups Projects
Commit c0b47bad authored by Cheng Hao's avatar Cheng Hao Committed by Michael Armbrust
Browse files

[SPARK-2767] [SQL] SparkSQL CLI doens't output error message if query failed.

Author: Cheng Hao <hao.cheng@intel.com>

Closes #1686 from chenghao-intel/spark_sql_cli and squashes the following commits:

eb664cc [Cheng Hao] Output detailed failure message in console
93b0382 [Cheng Hao] Fix Bug of no output in cli if exception thrown internally
parent 580c7011
No related branches found
No related tags found
No related merge requests found
......@@ -288,8 +288,10 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
out.println(cmd)
}
ret = driver.run(cmd).getResponseCode
val rc = driver.run(cmd)
ret = rc.getResponseCode
if (ret != 0) {
console.printError(rc.getErrorMessage())
driver.close()
return ret
}
......
......@@ -53,10 +53,9 @@ private[hive] class SparkSQLDriver(val context: HiveContext = SparkSQLEnv.hiveCo
}
override def run(command: String): CommandProcessorResponse = {
val execution = context.executePlan(context.hql(command).logicalPlan)
// TODO unify the error code
try {
val execution = context.executePlan(context.hql(command).logicalPlan)
hiveResponse = execution.stringResult()
tableSchema = getResultSetSchema(execution)
new CommandProcessorResponse(0)
......
......@@ -131,12 +131,13 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
@transient protected[hive] lazy val sessionState = {
val ss = new SessionState(hiveconf)
set(hiveconf.getAllProperties) // Have SQLConf pick up the initial set of HiveConf.
ss.err = new PrintStream(outputBuffer, true, "UTF-8")
ss.out = new PrintStream(outputBuffer, true, "UTF-8")
ss
}
sessionState.err = new PrintStream(outputBuffer, true, "UTF-8")
sessionState.out = new PrintStream(outputBuffer, true, "UTF-8")
override def set(key: String, value: String): Unit = {
super.set(key, value)
runSqlHive(s"SET $key=$value")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment