ueshin commented on code in PR #40015:
URL: https://github.com/apache/spark/pull/40015#discussion_r1160908837


##########
python/pyspark/sql/connect/plan.py:
##########
@@ -1830,14 +1831,24 @@ def plan(self, session: "SparkConnectClient") -> 
proto.Relation:
 
 
 class CacheTable(LogicalPlan):
-    def __init__(self, table_name: str) -> None:
+    def __init__(self, table_name: str, storage_level: Optional[StorageLevel] 
= None) -> None:
         super().__init__(None)
         self._table_name = table_name
-
-    def plan(self, session: "SparkConnectClient") -> proto.Relation:
-        plan = proto.Relation(
-            
catalog=proto.Catalog(cache_table=proto.CacheTable(table_name=self._table_name))
-        )
+        self._storage_level = storage_level
+
+    def plan(self, session: "SparkConnectClient") -> proto.Relation:
+        _cache_table = proto.CacheTable(table_name=self._table_name)
+        if self._storage_level:
+            _cache_table.storage_level.CopyFrom(
+                proto.StorageLevel(
+                    use_disk=self._storage_level.useDisk,
+                    use_memory=self._storage_level.useMemory,
+                    use_off_heap=self._storage_level.useOffHeap,
+                    deserialized=self._storage_level.deserialized,
+                    replication=self._storage_level.replication,
+                )

Review Comment:
   Shall we extract functions to convert to/from `proto.StorageLevel` and reuse 
them in `client.py` as well?



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to