HyukjinKwon commented on code in PR #46694:
URL: https://github.com/apache/spark/pull/46694#discussion_r1609195307


##########
python/pyspark/sql/tests/connect/test_connect_basic.py:
##########
@@ -1397,14 +1398,54 @@ def test_garbage_collection_checkpoint(self):
         )
 
         del df
+        gc.collect()
 
-        time.sleep(3)  # Make sure removing is triggered, and executed in the 
server.
+        def condition():
+            # Check the state was removed up on garbage-collection.
+            self.assertIsNone(
+                
session_holder.dataFrameCache().getOrDefault(cached_remote_relation_id, None)
+            )
+
+        eventually(catch_assertions=True)(condition)()
+
+    def test_garbage_collection_derived_checkpoint(self):
+        # SPARK-48258: Should keep the cached remote relation when derived 
DataFrames exist
+        df = self.connect.range(10).localCheckpoint()
+        self.assertIsNotNone(df._plan._relation_id)
+        derived = df.repartition(10)
+        cached_remote_relation_id = df._plan._relation_id
 
-        # Check the state was removed up on garbage-collection.
-        self.assertIsNone(
+        jvm = self.spark._jvm
+        session_holder = getattr(
+            getattr(
+                jvm.org.apache.spark.sql.connect.service,
+                "SparkConnectService$",
+            ),
+            "MODULE$",
+        ).getOrCreateIsolatedSession(self.connect.client._user_id, 
self.connect.client._session_id)
+
+        # Check the state exists.
+        self.assertIsNotNone(
             
session_holder.dataFrameCache().getOrDefault(cached_remote_relation_id, None)
         )
 
+        del df
+        gc.collect()

Review Comment:
   Unlike JVM, this does trigger the full GC



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