yihua commented on code in PR #13790:
URL: https://github.com/apache/hudi/pull/13790#discussion_r2305288706
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowArchivedCommitsProcedure.scala:
##########
@@ -78,13 +80,22 @@ class ShowArchivedCommitsProcedure(includeExtraMetadata:
Boolean) extends BasePr
override def call(args: ProcedureArgs): Seq[Row] = {
super.checkArgs(PARAMETERS, args)
- val table = getArgValueOrDefault(args,
PARAMETERS(0)).get.asInstanceOf[String]
- val limit = getArgValueOrDefault(args, PARAMETERS(1)).get.asInstanceOf[Int]
- var startTs = getArgValueOrDefault(args,
PARAMETERS(2)).get.asInstanceOf[String]
- var endTs = getArgValueOrDefault(args,
PARAMETERS(3)).get.asInstanceOf[String]
+ val tableName = getArgValueOrDefault(args, PARAMETERS(0))
+ val tablePath = getArgValueOrDefault(args, PARAMETERS(1))
+ val limit = getArgValueOrDefault(args, PARAMETERS(2)).get.asInstanceOf[Int]
+ var startTs = getArgValueOrDefault(args,
PARAMETERS(3)).get.asInstanceOf[String]
+ var endTs = getArgValueOrDefault(args,
PARAMETERS(4)).get.asInstanceOf[String]
+ val filter = getArgValueOrDefault(args,
PARAMETERS(5)).get.asInstanceOf[String]
+
+ if (filter != null && filter.trim.nonEmpty) {
+ HoodieProcedureFilterUtils.validateFilterExpression(filter, OUTPUT_TYPE,
sparkSession) match {
+ case Left(errorMessage) =>
+ throw new IllegalArgumentException(s"Invalid filter expression:
$errorMessage")
+ case Right(_) => // Validation passed, continue
+ }
+ }
Review Comment:
Should this be extract as a common util in `BaseProcedure`?
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/ShowArchivedCommitsProcedure.scala:
##########
@@ -105,6 +116,11 @@ class ShowArchivedCommitsProcedure(includeExtraMetadata:
Boolean) extends BasePr
// clear the instant details from memory after printing to reduce usage
archivedTimeline.clearInstantDetailsFromMemory(startTs, endTs)
}
+ if (filter != null && filter.trim.nonEmpty) {
+ HoodieProcedureFilterUtils.evaluateFilter(results, filter, OUTPUT_TYPE,
sparkSession)
+ } else {
+ results
+ }
Review Comment:
Similar here on extracting the logic for simplicity
--
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]