dongjoon-hyun 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_r266279706
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/AnalyzeColumnCommand.scala
 ##########
 @@ -89,6 +97,35 @@ 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) {
+      throw new AnalysisException("ANALYZE TABLE is not supported on views.")
 
 Review comment:
   Since this PR can analyze all cached plans, we need to remove this exception 
logically.
   For example, how do you think about the following case? Currently, this case 
fails due to this exception. It would be great if we can handle this too.
   ```scala
     test("database view") {
       withDatabase("db_v") {
         sql("CREATE DATABASE db_v")
         sql("CREATE VIEW db_v.v1 AS SELECT 1 c1")
         sql("CACHE TABLE db_v.v1")
         sql("ANALYZE TABLE db_v.v1 COMPUTE STATISTICS FOR COLUMNS c1")
         sql("SELECT * FROM db_v.v1").show
       }
     }
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to