From a393e28bdfc09dae02a12145c00f097e53f59293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=89=BF=E7=A5=A5?= Date: Tue, 25 Oct 2022 07:18:59 +0800 Subject: [PATCH] [MINOR] add commit_action output in show_commits (#7012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 苏承祥 --- .../sql/hudi/command/procedures/ShowCommitsProcedure.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowCommitsProcedure.scala b/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowCommitsProcedure.scala index 169acce887dd1..ddbad8100424c 100644 --- a/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowCommitsProcedure.scala +++ b/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowCommitsProcedure.scala @@ -22,8 +22,6 @@ import org.apache.hudi.common.model.HoodieCommitMetadata import org.apache.hudi.common.table.HoodieTableMetaClient import org.apache.hudi.common.table.timeline.{HoodieDefaultTimeline, HoodieInstant} import org.apache.spark.sql.Row -import org.apache.spark.sql.catalyst.TableIdentifier -import org.apache.spark.sql.catalyst.catalog.HoodieCatalogTable import org.apache.spark.sql.types.{DataTypes, Metadata, StructField, StructType} import java.util @@ -41,6 +39,7 @@ class ShowCommitsProcedure(includeExtraMetadata: Boolean) extends BaseProcedure private val OUTPUT_TYPE = new StructType(Array[StructField]( StructField("commit_time", DataTypes.StringType, nullable = true, Metadata.empty), + StructField("action", DataTypes.StringType, nullable = true, Metadata.empty), StructField("total_bytes_written", DataTypes.LongType, nullable = true, Metadata.empty), StructField("total_files_added", DataTypes.LongType, nullable = true, Metadata.empty), StructField("total_files_updated", DataTypes.LongType, nullable = true, Metadata.empty), @@ -135,7 +134,7 @@ class ShowCommitsProcedure(includeExtraMetadata: Boolean) extends BaseProcedure for (i <- 0 until newCommits.size) { val commit = newCommits.get(i) val commitMetadata = HoodieCommitMetadata.fromBytes(timeline.getInstantDetails(commit).get, classOf[HoodieCommitMetadata]) - rows.add(Row(commit.getTimestamp, commitMetadata.fetchTotalBytesWritten, commitMetadata.fetchTotalFilesInsert, + rows.add(Row(commit.getTimestamp, commit.getAction, commitMetadata.fetchTotalBytesWritten, commitMetadata.fetchTotalFilesInsert, commitMetadata.fetchTotalFilesUpdated, commitMetadata.fetchTotalPartitionsWritten, commitMetadata.fetchTotalRecordsWritten, commitMetadata.fetchTotalUpdateRecordsWritten, commitMetadata.fetchTotalWriteErrors))