cloud-fan commented on a change in pull request #35734:
URL: https://github.com/apache/spark/pull/35734#discussion_r820743765
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/CommandUtils.scala
##########
@@ -74,21 +74,44 @@ object CommandUtils extends Logging {
def calculateTotalSize(spark: SparkSession, catalogTable: CatalogTable):
BigInt = {
val sessionState = spark.sessionState
val startTime = System.nanoTime()
+
+ val isSymlinkTable =
SymlinkTextInputFormatUtil.isSymlinkTextFormat(catalogTable)
+ lazy val fs = new Path(catalogTable.location)
+ .getFileSystem(spark.sessionState.newHadoopConf())
val totalSize = if (catalogTable.partitionColumnNames.isEmpty) {
- calculateSingleLocationSize(sessionState, catalogTable.identifier,
- catalogTable.storage.locationUri)
+ if (isSymlinkTable) {
+ calculateMultipleLocationSizes(spark, catalogTable.identifier
+ , SymlinkTextInputFormatUtil.getSymlinkTableLocationPaths(fs,
catalogTable.location)
+ ).sum
+ } else {
+ calculateSingleLocationSize(sessionState, catalogTable.identifier,
+ catalogTable.storage.locationUri)
+ }
} else {
// Calculate table size as a sum of the visible partitions. See
SPARK-21079
val partitions =
sessionState.catalog.listPartitions(catalogTable.identifier)
logInfo(s"Starting to calculate sizes for ${partitions.length}
partitions.")
- val paths = partitions.map(_.storage.locationUri)
- calculateMultipleLocationSizes(spark, catalogTable.identifier, paths).sum
+ calculateMultipleLocationSizes(spark, catalogTable.identifier,
+ getPartitionPaths(partitions, isSymlinkTable, fs)).sum
}
logInfo(s"It took ${(System.nanoTime() - startTime) / (1000 * 1000)} ms to
calculate" +
s" the total size for table ${catalogTable.identifier}.")
totalSize
}
+ def getPartitionPaths(partitions: Seq[CatalogTablePartition]
+ , isSymlinkTable: Boolean, fs: => FileSystem):
Seq[Option[URI]] = {
+ partitions.flatMap { catalogTablePartition =>
+ if (isSymlinkTable) {
Review comment:
nit: 2 spaces indentation
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]