viirya commented on a change in pull request #25111: [SPARK-28346][SQL] clone 
the query plan between analyzer, optimizer and planner
URL: https://github.com/apache/spark/pull/25111#discussion_r303247858
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/InMemoryRelation.scala
 ##########
 @@ -166,18 +167,27 @@ object InMemoryRelation {
       outputOrdering: Seq[SortOrder],
       statsOfPlanToCache: Statistics): InMemoryRelation = {
     val relation = InMemoryRelation(output, cacheBuilder, outputOrdering)
-    relation.statsOfPlanToCache = statsOfPlanToCache
+    relation.setStatsOfPlanToCache(statsOfPlanToCache)
     relation
   }
+
+  val STATS_OF_PLAN_TO_CACHE_TAG = new 
TreeNodeTag[Statistics]("stats_of_plan_to_cache")
 }
 
 case class InMemoryRelation(
     output: Seq[Attribute],
     @transient cacheBuilder: CachedRDDBuilder,
     override val outputOrdering: Seq[SortOrder])
   extends logical.LeafNode with MultiInstanceRelation {
+  import InMemoryRelation.STATS_OF_PLAN_TO_CACHE_TAG
+
+  def setStatsOfPlanToCache(statsOfPlanToCache: Statistics): Unit = {
+    setTagValue(STATS_OF_PLAN_TO_CACHE_TAG, statsOfPlanToCache)
+  }
 
-  @volatile var statsOfPlanToCache: Statistics = null
+  def getStatsOfPlanToCache(): Statistics = {
+    getTagValue(STATS_OF_PLAN_TO_CACHE_TAG).get
+  }
 
 Review comment:
   Hmm, `statsOfPlanToCache` has `volatile` semantics. But making it as a 
`TreeNodeTag`, seems we don't preserve it? 

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