1717
1818package org .apache .spark .sql .hudi .command .procedures
1919
20+ import java .util .function .Supplier
2021import org .apache .hudi .HoodieCLIUtils
2122import org .apache .hudi .common .table .timeline .HoodieActiveTimeline
2223import org .apache .hudi .common .util .JsonUtils
@@ -25,7 +26,7 @@ import org.apache.spark.internal.Logging
2526import org .apache .spark .sql .Row
2627import org .apache .spark .sql .types .{DataTypes , Metadata , StructField , StructType }
2728
28- import java .util . function . Supplier
29+ import java .util
2930
3031class RunCleanProcedure extends BaseProcedure with ProcedureBuilder with Logging {
3132
@@ -74,16 +75,20 @@ class RunCleanProcedure extends BaseProcedure with ProcedureBuilder with Logging
7475 if (cleanPolicy.isDefined) {
7576 props += (HoodieCleanConfig .CLEANER_POLICY .key() -> String .valueOf(cleanPolicy.get))
7677 }
77- val client = HoodieCLIUtils .createHoodieClientFromPath(sparkSession, basePath, props, tableName )
78+ val client = HoodieCLIUtils .createHoodieClientFromPath(sparkSession, basePath, props)
7879 val hoodieCleanMeta = client.clean(cleanInstantTime, scheduleInLine, skipLocking)
80+ val rows = new util.ArrayList [Row ]
81+
82+ if (hoodieCleanMeta != null ) {
83+ rows.add(Row (hoodieCleanMeta.getStartCleanTime,
84+ hoodieCleanMeta.getTimeTakenInMillis,
85+ hoodieCleanMeta.getTotalFilesDeleted,
86+ hoodieCleanMeta.getEarliestCommitToRetain,
87+ JsonUtils .getObjectMapper.writeValueAsString(hoodieCleanMeta.getBootstrapPartitionMetadata),
88+ hoodieCleanMeta.getVersion))
89+ }
7990
80- if (hoodieCleanMeta == null ) Seq (Row .empty)
81- else Seq (Row (hoodieCleanMeta.getStartCleanTime,
82- hoodieCleanMeta.getTimeTakenInMillis,
83- hoodieCleanMeta.getTotalFilesDeleted,
84- hoodieCleanMeta.getEarliestCommitToRetain,
85- JsonUtils .getObjectMapper.writeValueAsString(hoodieCleanMeta.getBootstrapPartitionMetadata),
86- hoodieCleanMeta.getVersion))
91+ rows.stream().toArray().map(r => r.asInstanceOf [Row ]).toList
8792 }
8893}
8994
0 commit comments