Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18421#discussion_r128274136
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/AnalyzeTableCommand.scala
 ---
    @@ -37,31 +37,17 @@ case class AnalyzeTableCommand(
         if (tableMeta.tableType == CatalogTableType.VIEW) {
           throw new AnalysisException("ANALYZE TABLE is not supported on 
views.")
         }
    -    val newTotalSize = CommandUtils.calculateTotalSize(sessionState, 
tableMeta)
     
    -    val oldTotalSize = 
tableMeta.stats.map(_.sizeInBytes.toLong).getOrElse(-1L)
    -    val oldRowCount = 
tableMeta.stats.flatMap(_.rowCount.map(_.toLong)).getOrElse(-1L)
    -    var newStats: Option[CatalogStatistics] = None
    -    if (newTotalSize >= 0 && newTotalSize != oldTotalSize) {
    -      newStats = Some(CatalogStatistics(sizeInBytes = newTotalSize))
    -    }
    -    // We only set rowCount when noscan is false, because otherwise:
    -    // 1. when total size is not changed, we don't need to alter the table;
    -    // 2. when total size is changed, `oldRowCount` becomes invalid.
    -    // This is to make sure that we only record the right statistics.
    -    if (!noscan) {
    -      val newRowCount = sparkSession.table(tableIdentWithDB).count()
    -      if (newRowCount >= 0 && newRowCount != oldRowCount) {
    -        newStats = if (newStats.isDefined) {
    -          newStats.map(_.copy(rowCount = Some(BigInt(newRowCount))))
    -        } else {
    -          Some(CatalogStatistics(
    -            sizeInBytes = oldTotalSize, rowCount = 
Some(BigInt(newRowCount))))
    -        }
    +    // Compute stats for the whole table
    +    val newTotalSize = CommandUtils.calculateTotalSize(sessionState, 
tableMeta)
    +    val newRowCount =
    +      if (noscan) {
    +        None
    +      } else {
    +        Some(BigInt(sparkSession.table(tableIdentWithDB).count()))
           }
    -    }
    -    // Update the metastore if the above statistics of the table are 
different from those
    -    // recorded in the metastore.
    --- End diff --
    
    add it back?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to