linhongliu-db commented on code in PR #60412:
URL: https://github.com/apache/spark/pull/60412#discussion_r4590047980


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala:
##########
@@ -57,7 +58,10 @@ import org.apache.spark.storage.StorageLevel.MEMORY_AND_DISK
 case class CachedData(
     // A normalized resolved plan (See QueryExecution#normalized).
     plan: LogicalPlan,
-    cachedRepresentation: InMemoryRelation) {
+    cachedRepresentation: InMemoryRelation,
+    // Session values read by the session-context functions in `plan`, which 
the plan leaves
+    // unbound until after the cache lookup. See 
`CacheManager.sessionContextOf`.
+    sessionContext: Map[String, String] = Map.empty) {
   override def toString: String =

Review Comment:
   Done in 50353a1: `toString` includes `sessionContext`, and the miss log 
prints the input plan's context and each listed entry's context.



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala:
##########
@@ -507,13 +514,17 @@ class CacheManager extends Logging with 
AdaptiveSparkPlanHelper {
    */
   def lookupCachedData(session: SparkSession, plan: LogicalPlan): 
Option[CachedData] = {
     val normalized = QueryExecution.normalize(session, plan)
-    lookupCachedDataInternal(normalized)
+    lookupCachedDataInternal(normalized, session = Some(session))
   }
 
   private def lookupCachedDataInternal(
       plan: LogicalPlan,
-      canUse: CachedData => Boolean = _ => true): Option[CachedData] = {
-    val result = cachedData.find(cd => plan.sameResult(cd.plan) && canUse(cd))
+      canUse: CachedData => Boolean = _ => true,
+      // The session whose context a matching entry must share; the active one 
by default.
+      session: Option[SparkSession] = SparkSession.getActiveSession): 
Option[CachedData] = {

Review Comment:
   Done in 50353a1: `useCachedData` now takes the session explicitly 
(`QueryExecution` passes its `sparkSession`), and the `getActiveSession` 
default is gone.



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

To unsubscribe, e-mail: [email protected]

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