aokolnychyi commented on code in PR #52599:
URL: https://github.com/apache/spark/pull/52599#discussion_r2449676488
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala:
##########
@@ -3182,6 +3191,95 @@ class PlanResolutionSuite extends SharedSparkSession
with AnalysisTest {
assert(cmdAnalyzed.children.isEmpty)
}
+ test("relation resolution - cache key behavior with time travel") {
+ val ctx = AnalysisContext()
+ AnalysisContext.withAnalysisContext(ctx) {
+ assert(ctx.relationCache.isEmpty)
+
+ // create two unresolved relations without time travel
+ val unresolved1 = UnresolvedRelation(Seq("testcat", "tab"))
+ val unresolved2 = UnresolvedRelation(Seq("testcat", "tab"))
+
+ // resolve both relations
+ val resolved1 = resolve(unresolved1)
+ val resolved2 = resolve(unresolved2)
+
+ // relations without time travel should have None for timeTravelSpec
+ assert(resolved1.timeTravelSpec.isEmpty)
+ assert(resolved2.timeTravelSpec.isEmpty)
+
+ // after first resolution, cache should have 1 entry (without time
travel)
+ assert(ctx.relationCache.size == 1)
+ assert(ctx.relationCache.keys.head._2.isEmpty)
+
+ // create unresolved relation with time travel spec
+ val timeTravelSpec = AsOfVersion("v1")
+ val unresolved3 = UnresolvedRelation(Seq("testcat", "tab"))
+
+ // resolve with time travel
+ val resolved3 = resolve(unresolved3, Some(timeTravelSpec))
+
+ // relation with time travel should preserve the timeTravelSpec
+ assert(resolved3.timeTravelSpec.isDefined)
+ assert(resolved3.timeTravelSpec.get == timeTravelSpec)
+
+ // after time travel resolution, cache should have 2 entries (with and
without time travel)
+ assert(ctx.relationCache.size == 2)
+ }
+ }
+
+ test("relation resolution - plan ID cloning on cache hit") {
+ val ctx = AnalysisContext()
+ AnalysisContext.withAnalysisContext(ctx) {
+ assert(ctx.relationCache.isEmpty)
+
+ // create first unresolved relation with a plan ID
+ val unresolved1 = UnresolvedRelation(Seq("testcat", "tab"))
+ val planId1 = 12345L
+ unresolved1.setTagValue(LogicalPlan.PLAN_ID_TAG, planId1)
Review Comment:
I modified that piece of code so wanted to make sure this works too. I made
it time-travel specific.
--
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]