aokolnychyi commented on code in PR #56121:
URL: https://github.com/apache/spark/pull/56121#discussion_r3358283006


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala:
##########
@@ -489,16 +492,37 @@ class CacheManager extends Logging with 
AdaptiveSparkPlanHelper {
     result
   }
 
+  // Decides whether the cached entry can be substituted into a plan being 
executed inside
+  // the given transaction. Collects only the scans whose table belongs to the 
transaction's
+  // catalog and asks the connector whether reusing the cached snapshot is 
compatible with its
+  // isolation contract.
+  private def validateCachedEntryForTransaction(cd: CachedData, txn: 
Transaction): Boolean = {
+    val txnCatalogName = txn.catalog().name()
+    val txnTables = 
cd.cachedRepresentation.cacheBuilder.logicalPlan.collectWithSubqueries {
+      case r: DataSourceV2Relation if r.catalog.exists(_.name() == 
txnCatalogName) => r.table
+    }.toSet
+    val scans = 
collectWithSubqueries(cd.cachedRepresentation.cacheBuilder.cachedPlan) {
+      case b: BatchScanExec if txnTables.contains(b.table) => b.scan

Review Comment:
   I wonder if this is reliable and whether we should use reference equality 
rather than equals/hashCode.



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