yaooqinn commented on a change in pull request #1328:
URL: https://github.com/apache/incubator-kyuubi/pull/1328#discussion_r742554066



##########
File path: 
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala
##########
@@ -164,21 +166,18 @@ class ExecuteStatement(
   }
 
   override protected def runInternal(): Unit = {
-    if (shouldRunAsync) {
-      executeStatement()
-      val sessionManager = session.sessionManager
-      val asyncOperation = new Runnable {
-        override def run(): Unit = waitStatementComplete()
-      }
-      try {
-        val backgroundOperation =
-          sessionManager.submitBackgroundOperation(asyncOperation)
-        setBackgroundHandle(backgroundOperation)
-      } catch onError("submitting query in background, query rejected")
-    } else {
-      setState(OperationState.RUNNING)
-      executeStatement()
-      setState(OperationState.FINISHED)
+    executeStatement()
+    val sessionManager = session.sessionManager
+    val asyncOperation: Runnable = () => waitStatementComplete()
+    try {
+      val opHandle = sessionManager.submitBackgroundOperation(asyncOperation)
+      setBackgroundHandle(opHandle)
+    } catch onError("submitting query in background, query rejected")
+
+    if (!shouldRunAsync) try {
+      getBackgroundHandle.get()
+    } catch {
+      case _: ExecutionException => // ignore since state and exception are 
already updated

Review comment:
       in sync mode, clients do not get operation failure through 
GetOperationStatus API, but fail with execution failure directly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to