[KYUUBI #3898] Init operation log for ExecutePython to prevent error when fetching log

### _Why are the changes needed?_

To prevent the error as below:
<img width="1385" alt="image" src="https://user-images.githubusercontent.com/6757692/205498862-e162cd49-8aed-4f42-b51d-12d0b49c4e2d.png">

### _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 #3898 from turboFei/python_log.

Closes #3898

f9ec7a02 [fwang12] Init operation log for ExecutePython to prevent error when fetching log

Authored-by: fwang12 <fwang12@ebay.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
fwang12 2022-12-05 00:37:36 +08:00
parent f1218ae397
commit f3600012f8

View File

@ -35,6 +35,7 @@ import org.apache.kyuubi.Logging
import org.apache.kyuubi.config.KyuubiReservedKeys.{KYUUBI_SESSION_USER_KEY, KYUUBI_STATEMENT_ID_KEY}
import org.apache.kyuubi.engine.spark.KyuubiSparkUtil.SPARK_SCHEDULER_POOL_KEY
import org.apache.kyuubi.operation.ArrayFetchIterator
import org.apache.kyuubi.operation.log.OperationLog
import org.apache.kyuubi.session.Session
class ExecutePython(
@ -42,6 +43,9 @@ class ExecutePython(
override val statement: String,
worker: SessionPythonWorker) extends SparkOperation(session) {
private val operationLog: OperationLog = OperationLog.createOperationLog(session, getHandle)
override def getOperationLog: Option[OperationLog] = Option(operationLog)
override protected def resultSchema: StructType = {
if (result == null || result.schema.isEmpty) {
new StructType().add("output", "string")