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 2019/03/14 01:58:32 UTC

[GitHub] [spark] maropu commented on a change in pull request #24047: [SPARK-25196][SQL] Extends Analyze commands for cached tables

maropu commented on a change in pull request #24047: [SPARK-25196][SQL] Extends Analyze commands for cached tables 
URL: https://github.com/apache/spark/pull/24047#discussion_r265396160
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
 ##########
 @@ -181,6 +182,38 @@ class CacheManager extends Logging {
     }
   }
 
+  private[sql] def analyzeColumnCacheQuery(
+      query: Dataset[_],
+      column: Seq[Attribute]): Unit = writeLock {
+    val cachedData = lookupCachedData(query)
+    if (cachedData.isEmpty) {
+      logWarning("The cached data not found, so you need to cache the query first.")
+    } else {
+      cachedData.foreach { cachedData =>
+        val relation = cachedData.cachedRepresentation
+        val (rowCount, newColStats) =
+          CommandUtils.computeColumnStats(query.sparkSession, relation, column)
+        val oldStats = relation.statsOfPlanToCache
+        val newStats = oldStats.copy(
+          rowCount = Some(rowCount),
+          attributeStats = AttributeMap((oldStats.attributeStats ++ newColStats).toSeq)
+        )
+        relation.statsOfPlanToCache = newStats
+      }
+    }
+  }
+
+  /**
+   * Analyzes column statistics in an already-cached table.
+   *
+   * @param spark        The Spark session.
+   * @param tableName    The identifier of a cached table.
 
 Review comment:
   fixed

----------------------------------------------------------------
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