Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/18292#discussion_r126275485 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/AnalyzeColumnCommand.scala --- @@ -42,17 +42,20 @@ case class AnalyzeColumnCommand( if (tableMeta.tableType == CatalogTableType.VIEW) { throw new AnalysisException("ANALYZE TABLE is not supported on views.") } - val sizeInBytes = CommandUtils.calculateTotalSize(sessionState, tableMeta) + val newSize = CommandUtils.calculateTotalSize(sessionState, tableMeta) // Compute stats for each column - val (rowCount, newColStats) = computeColumnStats(sparkSession, tableIdentWithDB, columnNames) + val (newRowCount, colStats) = computeColumnStats(sparkSession, tableIdentWithDB, columnNames) + + // Because we will invalidate or update stats when table is changed, if column stats exist, + // they should be correct. Hence, we can combine previous column stats and the newly collected + // column stats. + val oldColStats = tableMeta.stats.map(_.colStats).getOrElse(Map.empty) + val newColStats = oldColStats ++ colStats // We also update table-level stats in order to keep them consistent with column-level stats. val statistics = CatalogStatistics( - sizeInBytes = sizeInBytes, - rowCount = Some(rowCount), - // Newly computed column stats should override the existing ones. - colStats = tableMeta.stats.map(_.colStats).getOrElse(Map.empty) ++ newColStats) --- End diff -- Yes. I did not find any semantics difference.
--- 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