You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2017/07/08 04:40:45 UTC

[GitHub] spark pull request #18292: [SPARK-21083][SQL] Do not remove correct column s...

Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18292#discussion_r126274515
  
    --- 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 --
    
    seems we already did it?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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