diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala index e10230ebfa0..8e4c5137fbf 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala @@ -61,9 +61,13 @@ class KyuubiBatchSession( override def createTime: Long = metadata.map(_.createTime).getOrElse(super.createTime) override def getNoOperationTime: Long = { - if (batchJobSubmissionOp != null && !OperationState.isTerminal( - batchJobSubmissionOp.getStatus.state)) { - 0L + if (batchJobSubmissionOp != null) { + val batchStatus = batchJobSubmissionOp.getStatus + if (!OperationState.isTerminal(batchStatus.state)) { + 0L + } else { + System.currentTimeMillis() - batchStatus.completed + } } else { super.getNoOperationTime }