imback82 commented on a change in pull request #30598:
URL: https://github.com/apache/spark/pull/30598#discussion_r536384428



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala
##########
@@ -706,3 +705,13 @@ case class ShowPartitions(
   override val output: Seq[Attribute] = Seq(
     AttributeReference("partition", StringType, nullable = false)())
 }
+
+/**
+ * The logical plan of the CACHE TABLE command.
+ */
+case class CacheTable(
+    table: LogicalPlan,
+    multipartIdentifier: Seq[String],
+    query: Option[LogicalPlan],

Review comment:
       > hmm, for the `query`, it should apply filter pushdown and contain 
`DataSourceV2ScanRelation`, right?
   
   We create a temp view and cache it as follow:
   ```scala
   Dataset.ofRows(sparkSession, query.get).createTempView(relationName)
   val df = sparkSession.table(relationName)
   sparkSession.sharedState.cacheManager.cacheQuery(df, Some(relationName))
   ```
   `cacheQuery` uses the "analyzed" plan of `df` to cache. The analyzed plan 
will have `DataSourceV2Relation` (but the optimized plan will have 
`DataSourceV2ScanRelation`).
   
   If we make the `query` as a child of the plan, `query` will be have an 
optimized plan `DataSourceV2ScanRelation`.
   




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to