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/20 22:33:20 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24047: [SPARK-25196][SQL] Extends the analyze column command for cached tables

dongjoon-hyun commented on a change in pull request #24047: [SPARK-25196][SQL] Extends the analyze column command for cached tables 
URL: https://github.com/apache/spark/pull/24047#discussion_r267573183
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/command/AnalyzeColumnCommand.scala
 ##########
 @@ -89,6 +97,46 @@ case class AnalyzeColumnCommand(
     columnsToAnalyze
   }
 
+  private def analyzeColumnInCatalog(sparkSession: SparkSession): Unit = {
+    val sessionState = sparkSession.sessionState
+    val tableMeta = sessionState.catalog.getTableMetadata(tableIdent)
+    if (tableMeta.tableType == CatalogTableType.VIEW) {
+      // Analyzes a catalog view if the view is cached
+      val cacheManager = sparkSession.sharedState.cacheManager
+      val plan = sparkSession.table(tableIdent.quotedString).logicalPlan
+      cacheManager.lookupCachedData(plan) match {
+        case Some(cachedData) =>
+          val columnsToAnalyze = getColumnsToAnalyze(
+            tableIdent, cachedData.plan, columnNames, allColumns)
+          cacheManager.analyzeColumnCacheQuery(sparkSession, cachedData, columnsToAnalyze)
+        case _ =>
+          throw new AnalysisException("ANALYZE TABLE is not supported on views.")
 
 Review comment:
   This can be `ANALYZE TABLE is not supported on views`, but I'm fine with the current one too because it's too specific case.

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