You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2015/10/29 18:29:58 UTC
spark git commit: [SPARK-11188][SQL] Elide stacktraces in
bin/spark-sql for AnalysisExceptions
Repository: spark
Updated Branches:
refs/heads/master f7a51deeb -> 8185f038c
[SPARK-11188][SQL] Elide stacktraces in bin/spark-sql for AnalysisExceptions
Only print the error message to the console for Analysis Exceptions in sql-shell.
Author: Dilip Biswal <db...@us.ibm.com>
Closes #9194 from dilipbiswal/spark-11188.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/8185f038
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/8185f038
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/8185f038
Branch: refs/heads/master
Commit: 8185f038c13c72e1bea7b0921b84125b7a352139
Parents: f7a51de
Author: Dilip Biswal <db...@us.ibm.com>
Authored: Thu Oct 29 18:29:50 2015 +0100
Committer: Michael Armbrust <mi...@databricks.com>
Committed: Thu Oct 29 18:29:50 2015 +0100
----------------------------------------------------------------------
.../spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala | 10 +++++++++-
.../spark/sql/hive/thriftserver/SparkSQLDriver.scala | 11 ++++++++---
.../apache/spark/sql/hive/thriftserver/CliSuite.scala | 12 ++++++++++--
3 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/8185f038/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
----------------------------------------------------------------------
diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
index b507396..62e912c 100644
--- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
+++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala
@@ -20,6 +20,8 @@ package org.apache.spark.sql.hive.thriftserver
import java.io._
import java.util.{ArrayList => JArrayList, Locale}
+import org.apache.spark.sql.AnalysisException
+
import scala.collection.JavaConverters._
import jline.console.ConsoleReader
@@ -298,6 +300,7 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
driver.init()
val out = sessionState.out
+ val err = sessionState.err
val start: Long = System.currentTimeMillis()
if (sessionState.getIsVerbose) {
out.println(cmd)
@@ -308,7 +311,12 @@ private[hive] class SparkSQLCLIDriver extends CliDriver with Logging {
ret = rc.getResponseCode
if (ret != 0) {
- console.printError(rc.getErrorMessage())
+ // For analysis exception, only the error is printed out to the console.
+ rc.getException() match {
+ case e : AnalysisException =>
+ err.println(s"""Error in query: ${e.getMessage}""")
+ case _ => err.println(rc.getErrorMessage())
+ }
driver.close()
return ret
}
http://git-wip-us.apache.org/repos/asf/spark/blob/8185f038/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLDriver.scala
----------------------------------------------------------------------
diff --git a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLDriver.scala b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLDriver.scala
index 2619286..f1ec723 100644
--- a/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLDriver.scala
+++ b/sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLDriver.scala
@@ -18,6 +18,8 @@
package org.apache.spark.sql.hive.thriftserver
import java.util.{Arrays, ArrayList => JArrayList, List => JList}
+import org.apache.log4j.LogManager
+import org.apache.spark.sql.AnalysisException
import scala.collection.JavaConverters._
@@ -63,9 +65,12 @@ private[hive] class SparkSQLDriver(
tableSchema = getResultSetSchema(execution)
new CommandProcessorResponse(0)
} catch {
- case cause: Throwable =>
- logError(s"Failed in [$command]", cause)
- new CommandProcessorResponse(1, ExceptionUtils.getStackTrace(cause), null)
+ case ae: AnalysisException =>
+ logDebug(s"Failed in [$command]", ae)
+ new CommandProcessorResponse(1, ExceptionUtils.getStackTrace(ae), null, ae)
+ case cause: Throwable =>
+ logError(s"Failed in [$command]", cause)
+ new CommandProcessorResponse(1, ExceptionUtils.getStackTrace(cause), null, cause)
}
}
http://git-wip-us.apache.org/repos/asf/spark/blob/8185f038/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
index 76d1591..3fa5c85 100644
--- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
+++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/CliSuite.scala
@@ -58,7 +58,7 @@ class CliSuite extends SparkFunSuite with BeforeAndAfter with Logging {
* @param timeout maximum time for the commands to complete
* @param extraArgs any extra arguments
* @param errorResponses a sequence of strings whose presence in the stdout of the forked process
- * is taken as an immediate error condition. That is: if a line beginning
+ * is taken as an immediate error condition. That is: if a line containing
* with one of these strings is found, fail the test immediately.
* The default value is `Seq("Error:")`
*
@@ -104,7 +104,7 @@ class CliSuite extends SparkFunSuite with BeforeAndAfter with Logging {
}
} else {
errorResponses.foreach { r =>
- if (line.startsWith(r)) {
+ if (line.contains(r)) {
foundAllExpectedAnswers.tryFailure(
new RuntimeException(s"Failed with error line '$line'"))
}
@@ -219,4 +219,12 @@ class CliSuite extends SparkFunSuite with BeforeAndAfter with Logging {
-> "OK"
)
}
+
+ test("SPARK-11188 Analysis error reporting") {
+ runCliWithin(timeout = 2.minute,
+ errorResponses = Seq("AnalysisException"))(
+ "select * from nonexistent_table;"
+ -> "Error in query: Table not found: nonexistent_table;"
+ )
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org