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/05/05 03:35:35 UTC

[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2529: [KYUUBI #2493] Implement the progress of statement

yaooqinn commented on code in PR #2529:
URL: https://github.com/apache/incubator-kyuubi/pull/2529#discussion_r865531508


##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/JobProgressUpdate.scala:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.operation
+
+import java.util
+
+import org.apache.commons.lang3.StringUtils
+import org.apache.hive.service.rpc.thrift.TJobExecutionStatus
+
+case class JobProgressUpdate(
+    headers: util.List[String] = null,
+    rows: util.List[util.List[String]] = null,
+    footerSummary: String = null,
+    progressedPercentage: Double = 0.0,
+    startTimeMillis: Long = 0L,
+    status: String = null)
+
+object KyuubiProgressMonitorStatusMapper {
+
+  def forStatus(status: String): TJobExecutionStatus = {
+    if (StringUtils.isEmpty(status)) {
+      return TJobExecutionStatus.NOT_AVAILABLE
+    }
+    KyuubiStatus.withName(status) match {
+      case KyuubiStatus.NOT_AVAILABLE =>
+        TJobExecutionStatus.NOT_AVAILABLE
+      case KyuubiStatus.IN_PROGRESS | KyuubiStatus.PENDING | KyuubiStatus.RUNNING =>
+        TJobExecutionStatus.IN_PROGRESS
+      case KyuubiStatus.COMPLETE => TJobExecutionStatus.COMPLETE
+      case _ => TJobExecutionStatus.COMPLETE
+    }
+  }
+}
+
+object KyuubiStatus extends Enumeration {

Review Comment:
   KyuubiStatus is a overkilling name



##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/progress/SparkProgressMonitor.scala:
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kyuubi.engine.spark.operation.progress
+
+import java.util
+
+import scala.collection.JavaConverters._
+
+import org.apache.kyuubi.engine.spark.operation.progress.SparkProgressMonitor._
+import org.apache.kyuubi.operation.KyuubiStatus
+
+class SparkProgressMonitor(progressMap: Map[SparkStage, SparkStageProgress], _startTime: Long = 0) {

Review Comment:
   unnecessary default value



##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/operation/progress/SparkStageProgress.scala:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kyuubi.engine.spark.operation.progress
+
+case class SparkStage(stageId: Int, attemptId: Int) extends Comparable[SparkStage] {

Review Comment:
   extends Comparable[SparkStage] is unnecessary



##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SparkProgressFetcher.scala:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.kyuubi
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.status.api.v1.StageStatus
+
+import org.apache.kyuubi.engine.spark.operation.progress.{SparkProgressMonitor, SparkStage, SparkStageProgress}
+import org.apache.kyuubi.operation.JobProgressUpdate
+
+class SparkProgressFetcher(spark: SparkSession, jobGroup: String) {
+
+  val statusStore = spark.sparkContext.statusStore
+
+  def getJobProgressUpdate(startTime: Long): JobProgressUpdate = {

Review Comment:
   the start time can be removed, it's just `operationStatus.start`



##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/OperationStatus.scala:
##########
@@ -27,4 +27,5 @@ case class OperationStatus(
     lastModified: Long,
     completed: Long,
     hasResultSet: Boolean,
-    exception: Option[KyuubiSQLException] = None)
+    exception: Option[KyuubiSQLException] = None,
+    jobProgressUpdate: Option[JobProgressUpdate] = None)

Review Comment:
   may be jobProgressUpdate: Option[TProgressUpdateResp] is OK to use



##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/JobProgressUpdate.scala:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.operation
+
+import java.util
+
+import org.apache.commons.lang3.StringUtils
+import org.apache.hive.service.rpc.thrift.TJobExecutionStatus
+
+case class JobProgressUpdate(

Review Comment:
   the default values seems useless



##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/JobProgressUpdate.scala:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.operation
+
+import java.util
+
+import org.apache.commons.lang3.StringUtils
+import org.apache.hive.service.rpc.thrift.TJobExecutionStatus
+
+case class JobProgressUpdate(
+    headers: util.List[String] = null,
+    rows: util.List[util.List[String]] = null,
+    footerSummary: String = null,
+    progressedPercentage: Double = 0.0,
+    startTimeMillis: Long = 0L,
+    status: String = null)
+
+object KyuubiProgressMonitorStatusMapper {
+
+  def forStatus(status: String): TJobExecutionStatus = {
+    if (StringUtils.isEmpty(status)) {
+      return TJobExecutionStatus.NOT_AVAILABLE
+    }
+    KyuubiStatus.withName(status) match {
+      case KyuubiStatus.NOT_AVAILABLE =>
+        TJobExecutionStatus.NOT_AVAILABLE
+      case KyuubiStatus.IN_PROGRESS | KyuubiStatus.PENDING | KyuubiStatus.RUNNING =>
+        TJobExecutionStatus.IN_PROGRESS
+      case KyuubiStatus.COMPLETE => TJobExecutionStatus.COMPLETE
+      case _ => TJobExecutionStatus.COMPLETE
+    }
+  }
+}
+
+object KyuubiStatus extends Enumeration {
+  type KyuubiStatus = Value
+  val PENDING, RUNNING, FINISHED, IN_PROGRESS, COMPLETE, NOT_AVAILABLE = Value

Review Comment:
   why is the status num more than TJobExecutionStatus



-- 
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