vamsikarnika commented on code in PR #17460:
URL: https://github.com/apache/hudi/pull/17460#discussion_r2602173223


##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowSavepointsProcedure.scala:
##########
@@ -17,24 +17,99 @@
 
 package org.apache.spark.sql.hudi.command.procedures
 
-import org.apache.hudi.common.table.timeline.{HoodieActiveTimeline, 
HoodieInstant, HoodieTimeline}
+import org.apache.hudi.common.table.timeline.{HoodieInstant, HoodieTimeline}
 
+import org.apache.spark.internal.Logging
 import org.apache.spark.sql.Row
 import org.apache.spark.sql.types.{DataTypes, Metadata, StructField, 
StructType}
 
-import java.util
 import java.util.function.Supplier
-import java.util.stream.Collectors
 
-class ShowSavepointsProcedure extends BaseProcedure with ProcedureBuilder {
+import scala.collection.JavaConverters._
+
+/**
+ * Spark SQL procedure to show all savepoints for a Hudi table.
+ *
+ * == Parameters ==
+ * - `table`: Required. The name of the Hudi table to query
+ * - `path`: Optional. The path of the Hudi table (anyone of `table` or `path` 
must be provided)
+ * - `limit`: Optional. Maximum number of savepoint operations to return 
(default: 10, ignored if time range specified)
+ * - `showArchived`: Optional. Whether to include archived savepoint 
operations (default: false)
+ * - `filter`: Optional. SQL expression to filter results (default: empty 
string)
+ * - `startTime`: Optional. Start time for savepoints (format: yyyyMMddHHmmss, 
default: empty)
+ * - `endTime`: Optional. End time for savepoints (format: yyyyMMddHHmmss, 
default: empty)
+ *
+ * == Output Schema ==
+ * - `savepoint_time`: Timestamp when the savepoint was created
+ * - `state_transition_time`: Time when the savepoint transitioned to 
completed state
+ * - `state`: Operation state (COMPLETED for savepoint)
+ * - `action`: The action type (always 'savepoint')
+ * - `savepointed_by`: User who created the savepoint
+ * - `savepointed_at`: Epoch timestamp when savepoint was created
+ * - `comments`: User comments for the savepoint
+ * - `partition_path`: Partition path (shows detailed partition info when 
available)
+ * - `savepoint_data_file`: Data file preserved by savepoint
+ * - `version`: Version of the savepoint metadata
+ *
+ * == Usage Examples ==
+ * {{{
+ * -- Basic usage: Show last 10 savepoints
+ * CALL show_savepoints(table => 'my_table')
+ *
+ * -- Include archived savepoint operations
+ * CALL show_savepoints(table => 'my_table', showArchived => true)
+ *
+ * -- Show savepoints within a time range (ignores limit)
+ * CALL show_savepoints(
+ *   table => 'my_table',
+ *   startTime => '20231201000000',
+ *   endTime => '20231205235959'
+ * )
+ *
+ * -- Show recent savepoints with limit
+ * CALL show_savepoints(
+ *   table => 'my_table',
+ *   startTime => '20231204000000',
+ *   limit => 5
+ * )
+ *
+ * -- Show savepoints with user filter
+ * CALL show_savepoints(
+ *   table => 'my_table',
+ *   filter => "savepointed_by = 'admin' AND comments LIKE '%backup%'"
+ * )
+ *
+ * -- Show partition-level savepoint details
+ * CALL show_savepoints(
+ *   table => 'my_table',
+ *   filter => "partition_path IS NOT NULL"
+ * )
+ * }}}
+ */
+class ShowSavepointsProcedure extends BaseProcedure with ProcedureBuilder with 
Logging {
   private val PARAMETERS = Array[ProcedureParameter](
     ProcedureParameter.optional(0, "table", DataTypes.StringType),
-    ProcedureParameter.optional(1, "path", DataTypes.StringType)
+    ProcedureParameter.optional(1, "path", DataTypes.StringType),
+    ProcedureParameter.optional(2, "limit", DataTypes.IntegerType, 10),
+    ProcedureParameter.optional(3, "showArchived", DataTypes.BooleanType, 
false),
+    ProcedureParameter.optional(4, "filter", DataTypes.StringType, ""),
+    ProcedureParameter.optional(5, "startTime", DataTypes.StringType, ""),
+    ProcedureParameter.optional(6, "endTime", DataTypes.StringType, "")

Review Comment:
   same here



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