andreaschat-db commented on code in PR #56121:
URL: https://github.com/apache/spark/pull/56121#discussion_r3362262266


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -2532,20 +2532,25 @@ class Analyzer(
      *     outer plan to get evaluated.
      */
     private def resolveSubQueries(plan: LogicalPlan, outer: LogicalPlan): 
LogicalPlan = {
+      // A subquery containing a V2TableReference also needs re-analysis: the 
placeholder is

Review Comment:
   Narrowed the fix. Now we should only replace the reference in already 
resolved plans.



##########
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 think this is by default implemented as a reference equality. If a 
connector decides to override this is responsible for provide a sane 
implementation. Is there any chance we replace the table instance between 
logical and physical plans? Any copy would break this.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Relation.scala:
##########
@@ -320,6 +320,7 @@ object ExtractV2ScanInfo {
 }
 
 object DataSourceV2Relation {
+

Review Comment:
   Removed.



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