diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala index 671d8ba6509..129fbc8d9aa 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala @@ -154,13 +154,23 @@ class BatchJobSubmission( engineId = appInfo.id, engineName = appInfo.name, engineUrl = appInfo.url.orNull, - engineState = appInfo.state.toString, + engineState = getAppState(state, appInfo.state).toString, engineError = appInfo.error, endTime = endTime) session.sessionManager.updateMetadata(metadataToUpdate) } } + private def getAppState( + opState: OperationState, + appState: ApplicationState.ApplicationState): ApplicationState.ApplicationState = { + if (opState == OperationState.ERROR && !ApplicationState.isTerminated(appState)) { + ApplicationState.UNKNOWN + } else { + appState + } + } + override def getOperationLog: Option[OperationLog] = Option(_operationLog) // we can not set to other state if it is canceled