rdblue commented on a change in pull request #24623: [SPARK-27739][SQL] 
df.persist should save stats from optimized plan
URL: https://github.com/apache/spark/pull/24623#discussion_r284804007
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
 ##########
 @@ -79,12 +79,13 @@ class CacheManager extends Logging {
       logWarning("Asked to cache already cached data.")
     } else {
       val sparkSession = query.sparkSession
+      val qe = sparkSession.sessionState.executePlan(planToCache)
       val inMemoryRelation = InMemoryRelation(
         sparkSession.sessionState.conf.useCompression,
         sparkSession.sessionState.conf.columnBatchSize, storageLevel,
-        sparkSession.sessionState.executePlan(planToCache).executedPlan,
+        qe.executedPlan,
         tableName,
-        planToCache)
+        qe.optimizedPlan)
 
 Review comment:
   I'm not sure that we can test this without filter pushdown in stats 
calculation.
   
   We've added filter pushdown, so the stats methods use `PhysicalOperation` to 
detect scans paired with projections and filters. When getting the stats for a 
scan, those filters are passed so that we can get accurate stats. Without that 
optimization, the stats would be identical between the analyzed plan and the 
optimized plan.

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


With regards,
Apache Git Services

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

Reply via email to