|
18 | 18 |
|
19 | 19 | package org.apache.paimon.spark.commands |
20 | 20 |
|
| 21 | +import org.apache.paimon.partition.PartitionStatistics |
21 | 22 | import org.apache.paimon.spark.catalyst.Compatibility |
22 | 23 | import org.apache.paimon.spark.leafnode.PaimonLeafRunnableCommand |
23 | 24 |
|
24 | 25 | import org.apache.spark.sql.{Row, SparkSession} |
25 | 26 | import org.apache.spark.sql.catalyst.analysis.ResolvedPartitionSpec |
26 | 27 | import org.apache.spark.sql.catalyst.catalog.ExternalCatalogUtils.escapePathName |
27 | | -import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Literal, ToPrettyString} |
| 28 | +import org.apache.spark.sql.catalyst.expressions.{Attribute, Literal} |
28 | 29 | import org.apache.spark.sql.connector.catalog.{Identifier, SupportsPartitionManagement, TableCatalog} |
29 | 30 | import org.apache.spark.sql.connector.catalog.PaimonCatalogImplicits._ |
30 | 31 | import org.apache.spark.sql.execution.datasources.v2.DataSourceV2Implicits._ |
@@ -87,7 +88,20 @@ case class PaimonShowTablePartitionCommand( |
87 | 88 | val partitionValues = partitions.mkString("[", ", ", "]") |
88 | 89 | results.put("Partition Values", s"$partitionValues") |
89 | 90 |
|
90 | | - // TODO "Partition Parameters", "Created Time", "Last Access", "Partition Statistics" |
| 91 | + // Partition Parameters and Partition Statistics |
| 92 | + val metadata = partitionTable.loadPartitionMetadata(row) |
| 93 | + if (!metadata.isEmpty) { |
| 94 | + val metadataMap = metadata.asScala |
| 95 | + results.put( |
| 96 | + "Partition Parameters", |
| 97 | + s"{${metadataMap.map { case (k, v) => s"$k=$v" }.mkString(", ")}}") |
| 98 | + |
| 99 | + val fileSizeInBytes = |
| 100 | + metadataMap.getOrElse(PartitionStatistics.FIELD_FILE_SIZE_IN_BYTES, "0").toLong |
| 101 | + val recordCount = |
| 102 | + metadataMap.getOrElse(PartitionStatistics.FIELD_RECORD_COUNT, "0").toLong |
| 103 | + results.put("Partition Statistics", s"$recordCount rows, $fileSizeInBytes bytes") |
| 104 | + } |
91 | 105 |
|
92 | 106 | results |
93 | 107 | .map { |
|
0 commit comments