danny0405 commented on code in PR #18195:
URL: https://github.com/apache/hudi/pull/18195#discussion_r2810697593


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/ShowHoodieTablePartitionsCommand.scala:
##########
@@ -44,18 +44,26 @@ case class ShowHoodieTablePartitionsCommand(
 
     val schemaOpt = hoodieCatalogTable.tableSchema
     val partitionColumnNamesOpt = 
hoodieCatalogTable.tableConfig.getPartitionFields
+    val useSlashSeparatedDatePartitioning = 
hoodieCatalogTable.tableConfig.getSlashSeparatedDatePartitioning
 
-    if (partitionColumnNamesOpt.isPresent && 
partitionColumnNamesOpt.get.nonEmpty && schemaOpt.nonEmpty) {
-      specOpt.map { spec =>
-        hoodieCatalogTable.getPartitionPaths.filter { partitionPath =>
-          val part = PartitioningUtils.parsePathFragment(partitionPath)
-          spec.forall { case (col, value) =>
-            PartitionPathEncodeUtils.escapePartitionValue(value) == 
part.getOrElse(col, null)
+      if (partitionColumnNamesOpt.isPresent && 
partitionColumnNamesOpt.get.nonEmpty && schemaOpt.nonEmpty) {
+        val partitions: Seq[Row] = specOpt.map { spec =>
+            hoodieCatalogTable.getPartitionPaths.filter { partitionPath =>
+              val part = PartitioningUtils.parsePathFragment(partitionPath)
+              spec.forall { case (col, value) =>
+                PartitionPathEncodeUtils.escapePartitionValue(value) == 
part.getOrElse(col, null)
+              }
+            }
           }
-        }
-      }
-        .getOrElse(hoodieCatalogTable.getPartitionPaths)
-        .map(Row(_))
+          .getOrElse(hoodieCatalogTable.getPartitionPaths)
+          .map(partitionVal => if (useSlashSeparatedDatePartitioning) {
+            ValidationUtils.checkState(partitionColumnNamesOpt.get().length == 
1,
+              "Only one partition field is allowed for 
SlashEncodedPartitioning")
+            Row(partitionColumnNamesOpt.get()(0) + "=" + 
partitionVal.replace('/', '-'))
+          } else {
+            Row(partitionVal)
+          })
+        partitions

Review Comment:
   this local variable could be inlined?



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