stream2000 commented on code in PR #7304:
URL: https://github.com/apache/hudi/pull/7304#discussion_r1032571122


##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunClusteringProcedure.scala:
##########
@@ -108,36 +138,42 @@ class RunClusteringProcedure extends BaseProcedure
     var client: SparkRDDWriteClient[_] = null
     try {
       client = HoodieCLIUtils.createHoodieClientFromPath(sparkSession, 
basePath, conf)
-      val instantTime = HoodieActiveTimeline.createNewInstantTime
-      if (client.scheduleClusteringAtInstant(instantTime, HOption.empty())) {
-        pendingClustering ++= Seq(instantTime)
+      if (operator.isSchedule) {
+        val instantTime = HoodieActiveTimeline.createNewInstantTime
+        if (client.scheduleClusteringAtInstant(instantTime, HOption.empty())) {
+          pendingClustering ++= Seq(instantTime)
+        }
       }
       logInfo(s"Clustering instants to run: 
${pendingClustering.mkString(",")}.")
 
-      val startTs = System.currentTimeMillis()
-      pendingClustering.foreach(client.cluster(_, true))
-      logInfo(s"Finish clustering all the instants: 
${pendingClustering.mkString(",")}," +
-        s" time cost: ${System.currentTimeMillis() - startTs}ms.")
-
-      val clusteringInstants = 
metaClient.reloadActiveTimeline().getInstants.iterator().asScala
-        .filter(p => p.getAction == HoodieTimeline.REPLACE_COMMIT_ACTION && 
pendingClustering.contains(p.getTimestamp))
-        .toSeq
-        .sortBy(f => f.getTimestamp)
-        .reverse
-
-      val clusteringPlans = clusteringInstants.map(instant =>
-        ClusteringUtils.getClusteringPlan(metaClient, instant)
-      )
-
-      if (showInvolvedPartitions) {
-        clusteringPlans.map { p =>
-          Row(p.get().getLeft.getTimestamp, 
p.get().getRight.getInputGroups.size(),
-            p.get().getLeft.getState.name(), 
HoodieCLIUtils.extractPartitions(p.get().getRight.getInputGroups.asScala))
+      if (operator.isExecute) {
+        val startTs = System.currentTimeMillis()
+        pendingClustering.foreach(client.cluster(_, true))
+        logInfo(s"Finish clustering all the instants: 
${pendingClustering.mkString(",")}," +
+          s" time cost: ${System.currentTimeMillis() - startTs}ms.")
+
+        val clusteringInstants = 
metaClient.reloadActiveTimeline().getInstants.iterator().asScala
+          .filter(p => p.getAction == HoodieTimeline.REPLACE_COMMIT_ACTION && 
pendingClustering.contains(p.getTimestamp))
+          .toSeq
+          .sortBy(f => f.getTimestamp)
+          .reverse
+
+        val clusteringPlans = clusteringInstants.map(instant =>
+          ClusteringUtils.getClusteringPlan(metaClient, instant)
+        )
+
+        if (showInvolvedPartitions) {

Review Comment:
   Can we also showInvolvedPartitions when operator.isSchedule is set? 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to