[KYUUBI-164]display root casue of statement failure on client size (#165)

* [KYUUBI-164]display root casue of statement failure on client size

* fix ut

* fix ut
This commit is contained in:
Kent Yao 2019-03-12 17:05:50 +08:00 committed by GitHub
parent 0ab29e5d64
commit 56fa56a880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 12 deletions

View File

@ -387,25 +387,28 @@ class KyuubiOperation(session: KyuubiSession, statement: String) extends Logging
}
case e: ParseException =>
if (!isClosedOrCanceled) {
onStatementError(
statementId, e.withCommand(statement).getMessage, KyuubiSparkUtil.exceptionString(e))
val err = KyuubiSparkUtil.exceptionString(e)
onStatementError(statementId, e.withCommand(statement).getMessage, err)
throw new KyuubiSQLException(
e.withCommand(statement).getMessage, "ParseException", 2000, e)
e.withCommand(statement).getMessage + err, "ParseException", 2000, e)
}
case e: AnalysisException =>
if (!isClosedOrCanceled) {
onStatementError(statementId, e.getMessage, KyuubiSparkUtil.exceptionString(e))
throw new KyuubiSQLException(e.getMessage, "AnalysisException", 2001, e)
val err = KyuubiSparkUtil.exceptionString(e)
onStatementError(statementId, e.getMessage, err)
throw new KyuubiSQLException(err, "AnalysisException", 2001, e)
}
case e: HiveAccessControlException =>
if (!isClosedOrCanceled) {
onStatementError(statementId, e.getMessage, KyuubiSparkUtil.exceptionString(e))
throw new KyuubiSQLException(e.getMessage, "HiveAccessControlException", 3000, e)
val err = KyuubiSparkUtil.exceptionString(e)
onStatementError(statementId, e.getMessage, err)
throw new KyuubiSQLException(err, "HiveAccessControlException", 3000, e)
}
case e: Throwable =>
if (!isClosedOrCanceled) {
onStatementError(statementId, e.getMessage, KyuubiSparkUtil.exceptionString(e))
throw new KyuubiSQLException(e.toString, "<unknown>", 10000, e)
val err = KyuubiSparkUtil.exceptionString(e)
onStatementError(statementId, e.getMessage, err)
throw new KyuubiSQLException(err, "<unknown>", 10000, e)
}
} finally {
if (statementId != null) {

View File

@ -181,8 +181,17 @@ class SparkSessionWithUGI(
}
}
stopContext()
val ke = new KyuubiSQLException(
s"Get SparkSession for [$userName] failed", "08S01", 1001, findCause(e))
val cause = findCause(e)
val msg =
s"""
|Get SparkSession for [$userName] failed
|Diagnosis:
|${sparkException.map(_.getMessage).getOrElse(cause.getMessage)}
|
|Please check if the specified yarn queue [${conf.getOption(QUEUE).getOrElse("")}]
|is available or has sufficient resources left
""".stripMargin
val ke = new KyuubiSQLException(msg, "08S01", 1001, cause)
sparkException.foreach(ke.addSuppressed)
throw ke
} finally {

View File

@ -153,7 +153,7 @@ class SparkSessionWithUGISuite extends SparkFunSuite {
assert(!SparkSessionWithUGI.isPartiallyConstructed(userName1))
val e = intercept[KyuubiSQLException](sparkSessionWithUGI.init(Map.empty))
assert(e.getCause.isInstanceOf[TimeoutException])
assert(e.getMessage.startsWith("Get SparkSession"))
assert(e.getMessage.contains("Get SparkSession"))
}
test("testSetFullyConstructed") {