You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ya...@apache.org on 2022/04/29 10:30:42 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #2490] Fix NPE in getOperationStatus

This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 96da2544f [KYUUBI #2490] Fix NPE in getOperationStatus
96da2544f is described below

commit 96da2544fbe8bdffec7cbd669a671c8311f3bbe3
Author: wforget <64...@qq.com>
AuthorDate: Fri Apr 29 18:30:33 2022 +0800

    [KYUUBI #2490] Fix NPE in getOperationStatus
    
    ### _Why are the changes needed?_
    
    close #2490
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #2509 from wForget/KYUUBI-2490.
    
    Closes #2490
    
    8d710fb9 [wforget] refactor and add test
    afaf240c [wforget] [KYUUBI-2490] Fix NPE in getOperationStatus
    
    Authored-by: wforget <64...@qq.com>
    Signed-off-by: Kent Yao <ya...@apache.org>
---
 .../kyuubi/engine/hive/operation/ExecuteStatement.scala    |  6 ++++--
 .../kyuubi/engine/hive/operation/HiveOperationSuite.scala  | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/ExecuteStatement.scala b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/ExecuteStatement.scala
index b4b8c099b..dc9d82c20 100644
--- a/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/ExecuteStatement.scala
+++ b/externals/kyuubi-hive-sql-engine/src/main/scala/org/apache/kyuubi/engine/hive/operation/ExecuteStatement.scala
@@ -30,7 +30,7 @@ class ExecuteStatement(
     session: Session,
     override val statement: String,
     confOverlay: Map[String, String],
-    override val shouldRunAsync: Boolean,
+    runAsync: Boolean,
     queryTimeout: Long)
   extends HiveOperation(OperationType.EXECUTE_STATEMENT, session) {
 
@@ -39,9 +39,11 @@ class ExecuteStatement(
       hive,
       statement,
       confOverlay.asJava,
-      shouldRunAsync,
+      runAsync,
       queryTimeout)
   }
 
   EventBus.post(HiveOperationEvent(this))
+
+  override def shouldRunAsync: Boolean = runAsync && getBackgroundHandle != null
 }
diff --git a/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala b/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
index 3595b35c2..1c4a6b704 100644
--- a/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
+++ b/externals/kyuubi-hive-sql-engine/src/test/scala/org/apache/kyuubi/engine/hive/operation/HiveOperationSuite.scala
@@ -18,6 +18,7 @@
 package org.apache.kyuubi.engine.hive.operation
 
 import org.apache.commons.lang3.{JavaVersion, SystemUtils}
+import org.apache.hive.service.rpc.thrift.{TExecuteStatementReq, TGetOperationStatusReq, TStatusCode}
 
 import org.apache.kyuubi.{HiveEngineTests, Utils}
 import org.apache.kyuubi.engine.hive.HiveSQLEngine
@@ -49,4 +50,17 @@ class HiveOperationSuite extends HiveEngineTests {
       assert(kyuubiStatement.getQueryId != null)
     }
   }
+
+  test("test set command") {
+    withSessionHandle { (client, handle) =>
+      val req = new TExecuteStatementReq()
+      req.setSessionHandle(handle)
+      req.setRunAsync(true)
+      req.setStatement("set hive.query.name=test")
+      val resp = client.ExecuteStatement(req)
+      val getStatusReq = new TGetOperationStatusReq(resp.getOperationHandle)
+      val getStatusResp = client.GetOperationStatus(getStatusReq)
+      assert(getStatusResp.getStatus.getStatusCode === TStatusCode.SUCCESS_STATUS)
+    }
+  }
 }