[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 <yikaifei1@gmail.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
Yikf 2023-01-10 19:09:26 +08:00 committed by fwang12
parent 2fef966544
commit 679810fe11
2 changed files with 22 additions and 1 deletions

View File

@ -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) {

View File

@ -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)
}
}
}