You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/04/18 10:01:41 UTC

[GitHub] [incubator-kyuubi] ulysses-you commented on pull request #2202: [KYUUBI #2201] Show ExecutionId when running status on query engine page

ulysses-you commented on PR #2202:
URL: https://github.com/apache/incubator-kyuubi/pull/2202#issuecomment-1101279496

   can we simplify code to:
   
   ```scala
   --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/ExecuteStatement.scala
   +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/ExecuteStatement.scala
   @@ -23,6 +23,7 @@ import scala.collection.JavaConverters._
   
    import org.apache.spark.kyuubi.SQLOperationListener
    import org.apache.spark.sql.Row
   +import org.apache.spark.sql.catalyst.QueryPlanningTracker
    import org.apache.spark.sql.types._
   
    import org.apache.kyuubi.{KyuubiSQLException, Logging}
   @@ -79,8 +80,7 @@ class ExecuteStatement(
          // TODO: Make it configurable
          spark.sparkContext.addSparkListener(operationListener)
          result = spark.sql(statement)
   -      // TODO #921: COMPILED need consider eagerly executed commands
   -      setState(OperationState.COMPILED)
   +      setCompiledState(result.queryExecution.tracker)
          debug(result.queryExecution)
          iter =
            if (incrementalCollect) {
   @@ -158,4 +158,17 @@ class ExecuteStatement(
        EventBus.post(
          SparkOperationEvent(this, operationListener.getExecutionId))
      }
   +
   +  private def setCompiledState(tracker: QueryPlanningTracker): Unit = {
   +    super.setState(OperationState.COMPILED)
   +
   +    val phase = tracker.phases
   +    if (phase.contains("parsing") && phase.contains("planning")) {
   +      val compiledTime = phase("planning").endTimeMs - phase("parsing").startTimeMs
   +      lastAccessTime = lastAccessTime + compiledTime
   +    }
   +
   +    EventBus.post(
   +      SparkOperationEvent(this, operationListener.getExecutionId))
   +  }
    }
   ```


-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org