You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/18 06:55:07 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #27129: [SPARK-30427][SQL] Add config item for limiting partition number when calculating statistics through File System

HyukjinKwon commented on a change in pull request #27129: [SPARK-30427][SQL] Add config item for limiting partition number when calculating statistics through File System
URL: https://github.com/apache/spark/pull/27129#discussion_r380486918
 
 

 ##########
 File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/PruneHiveTablePartitions.scala
 ##########
 @@ -73,19 +74,30 @@ private[sql] class PruneHiveTablePartitions(session: SparkSession)
   private def updateTableMeta(
       tableMeta: CatalogTable,
       prunedPartitions: Seq[CatalogTablePartition]): CatalogTable = {
-    val sizeOfPartitions = prunedPartitions.map { partition =>
+    val partitionsWithSize = prunedPartitions.map { partition =>
       val rawDataSize = partition.parameters.get(StatsSetupConst.RAW_DATA_SIZE).map(_.toLong)
       val totalSize = partition.parameters.get(StatsSetupConst.TOTAL_SIZE).map(_.toLong)
       if (rawDataSize.isDefined && rawDataSize.get > 0) {
-        rawDataSize.get
+        (partition, rawDataSize.get)
       } else if (totalSize.isDefined && totalSize.get > 0L) {
-        totalSize.get
+        (partition, totalSize.get)
       } else {
-        0L
+        (partition, 0L)
       }
     }
-    if (sizeOfPartitions.forall(_ > 0)) {
-      val sizeInBytes = sizeOfPartitions.sum
+    if (partitionsWithSize.forall(_._2 > 0)) {
+      val sizeInBytes = partitionsWithSize.map(_._2).sum
+      tableMeta.copy(stats = Some(CatalogStatistics(sizeInBytes = BigInt(sizeInBytes))))
+    } else if (partitionsWithSize.count(_._2 == 0) <= conf.maxPartNumForStatsCalculateViaFS) {
 
 Review comment:
   @fuwhu, are you're proposing a configuration to automatically calculate the size? why don't you just manually run analyze comment to calculate the stats? It's weird to do this based on the number of partitions.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org