Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ private[hive] class SparkExecuteStatementOperation(
dataTypes = result.queryExecution.analyzed.output.map(_.dataType).toArray
} catch {
case e: HiveSQLException =>
HiveThriftServer2.listener.onStatementError(
statementId, e.getMessage, SparkUtils.exceptionString(e))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried your code. there seems have a bug.
e.getMessage may get a null value, which may cause NPE in ThriftServerPage.errorMessageCell(detail)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR still occurs in Spark 2.2.1. A workaround is to use "String.valueOf(e.getMessage)" instead of "e.getMessage" to avoid of NPE problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but My pr is closed by community...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please catch the exception in ThriftServerPage.errorMessageCell. Without my pr, that function still throw exception.

if (getStatus().getState() == OperationState.CANCELED) {
return
} else {
Expand All @@ -252,13 +254,35 @@ private[hive] class SparkExecuteStatementOperation(
case e: Throwable =>
val currentState = getStatus().getState()
logError(s"Error executing query, currentState $currentState, ", e)
setState(OperationState.ERROR)
HiveThriftServer2.listener.onStatementError(
statementId, e.getMessage, SparkUtils.exceptionString(e))
if (statementId != null) {
sqlContext.sparkContext.cancelJobGroup(statementId)
}
getStatus().getState() match {
case OperationState.INITIALIZED =>
setState(OperationState.CLOSED)
case OperationState.CANCELED =>
case OperationState.FINISHED =>
case OperationState.CLOSED =>
case OperationState.ERROR =>
case _ =>
setState(OperationState.ERROR)
}

throw new HiveSQLException(e.toString)
}
setState(OperationState.FINISHED)
HiveThriftServer2.listener.onStatementFinish(statementId)
getStatus().getState() match {
case OperationState.INITIALIZED =>
setState(OperationState.CLOSED)
case OperationState.CANCELED =>
case OperationState.FINISHED =>
case OperationState.CLOSED =>
case OperationState.ERROR =>
case _ =>
setState(OperationState.FINISHED)
}
}

override def cancel(): Unit = {
Expand Down