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

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


The following commit(s) were added to refs/heads/master by this push:
     new 679810fe1 [KYUUBI #4111] JDBC ExecuteStatement operation should 
contain operationLog
679810fe1 is described below

commit 679810fe11e33f9fabaee832781e2ae3f138936a
Author: Yikf <[email protected]>
AuthorDate: Tue Jan 10 19:09:26 2023 +0800

    [KYUUBI #4111] JDBC ExecuteStatement operation should contain operationLog
    
    ### _Why are the changes needed?_
    
    Close https://github.com/apache/kyuubi/issues/4111, JDBC ExecuteStatement 
operation should contain operationLog
    ### _How was this patch tested?_
    - [x] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run 
test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4113 from Yikf/KYUUBI-4111.
    
    Closes #4111
    
    172852070 [Yikf] Operations without log fetch log should fetch empty 
instead of report an error
    
    Authored-by: Yikf <[email protected]>
    Signed-off-by: fwang12 <[email protected]>
---
 .../engine/jdbc/operation/ExecuteStatement.scala      |  4 ++++
 .../engine/jdbc/doris/OperationWithEngineSuite.scala  | 19 ++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/ExecuteStatement.scala
 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/ExecuteStatement.scala
index 78f238e26..ef49f2b30 100644
--- 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/ExecuteStatement.scala
+++ 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/ExecuteStatement.scala
@@ -23,6 +23,7 @@ import org.apache.kyuubi.engine.jdbc.schema.{Column, Row, 
Schema}
 import org.apache.kyuubi.engine.jdbc.session.JdbcSessionImpl
 import org.apache.kyuubi.engine.jdbc.util.ResultSetWrapper
 import org.apache.kyuubi.operation.{ArrayFetchIterator, IterableFetchIterator, 
OperationState}
+import org.apache.kyuubi.operation.log.OperationLog
 import org.apache.kyuubi.session.Session
 
 class ExecuteStatement(
@@ -33,6 +34,9 @@ class ExecuteStatement(
     incrementalCollect: Boolean)
   extends JdbcOperation(session) with Logging {
 
+  private val operationLog: OperationLog = 
OperationLog.createOperationLog(session, getHandle)
+  override def getOperationLog: Option[OperationLog] = Option(operationLog)
+
   override protected def runInternal(): Unit = {
     addTimeoutMonitor(queryTimeout)
     if (shouldRunAsync) {
diff --git 
a/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/doris/OperationWithEngineSuite.scala
 
b/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/doris/OperationWithEngineSuite.scala
index a1814e702..d5e3f4f0f 100644
--- 
a/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/doris/OperationWithEngineSuite.scala
+++ 
b/externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/doris/OperationWithEngineSuite.scala
@@ -16,7 +16,7 @@
  */
 package org.apache.kyuubi.engine.jdbc.doris
 
-import org.apache.hive.service.rpc.thrift.{TGetInfoReq, TGetInfoType}
+import org.apache.hive.service.rpc.thrift.{TExecuteStatementReq, 
TFetchResultsReq, TGetInfoReq, TGetInfoType, TStatusCode}
 
 import org.apache.kyuubi.config.KyuubiConf
 import org.apache.kyuubi.engine.jdbc.connection.ConnectionProvider
@@ -59,4 +59,21 @@ class OperationWithEngineSuite extends DorisOperationSuite 
with HiveJDBCTestHelp
       }
     }
   }
+
+  test("JDBC ExecuteStatement operation should contain operationLog") {
+    withSessionHandle { (client, handle) =>
+      val tExecuteStatementReq = new TExecuteStatementReq()
+      tExecuteStatementReq.setSessionHandle(handle)
+      tExecuteStatementReq.setStatement("SELECT 1")
+      val tExecuteStatementResp = client.ExecuteStatement(tExecuteStatementReq)
+
+      val tFetchResultsReq = new TFetchResultsReq()
+      
tFetchResultsReq.setOperationHandle(tExecuteStatementResp.getOperationHandle)
+      tFetchResultsReq.setFetchType(1)
+      tFetchResultsReq.setMaxRows(1)
+
+      val tFetchResultsResp = client.FetchResults(tFetchResultsReq)
+      assert(tFetchResultsResp.getStatus.getStatusCode === 
TStatusCode.SUCCESS_STATUS)
+    }
+  }
 }

Reply via email to