wangyum commented on a change in pull request #24523: [SPARK-27631][SQL] Avoid 
repeating calculate table statistics when AUTO_SIZE_UPDATE_ENABLED is enabled
URL: https://github.com/apache/spark/pull/24523#discussion_r283082758
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/CommandUtils.scala
 ##########
 @@ -45,9 +45,13 @@ object CommandUtils extends Logging {
     val catalog = sparkSession.sessionState.catalog
     if (sparkSession.sessionState.conf.autoSizeUpdateEnabled) {
       val newTable = catalog.getTableMetadata(table.identifier)
-      val newSize = CommandUtils.calculateTotalSize(sparkSession, newTable)
-      val newStats = CatalogStatistics(sizeInBytes = newSize)
-      catalog.alterTableStats(table.identifier, Some(newStats))
+      if (newTable.stats == table.stats) {
+        val newSize = CommandUtils.calculateTotalSize(sparkSession, newTable)
+        val newStats = CatalogStatistics(sizeInBytes = newSize)
+        catalog.alterTableStats(table.identifier, Some(newStats))
+      } else {
+        logInfo(s"Skip to update statistics for ${table.qualifiedName} as it 
updated by Hive.")
 
 Review comment:
   Yes. It supports from 0.13 to 2.3 and 3.1.
   Only Hive 0.12 does not calculate statistics. So it will be calculated by 
Spark.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to