Skip to content

Commit

Permalink
add commit_action output in show_commits
Browse files Browse the repository at this point in the history
  • Loading branch information
苏承祥 committed Oct 20, 2022
1 parent e6eb4e6 commit 8ea6016
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 8ea6016

Please sign in to comment.