Prathamesh9284 commented on code in PR #1376:
URL: 
https://github.com/apache/datafusion-python/pull/1376#discussion_r2794954967


##########
python/datafusion/substrait.py:
##########
@@ -137,6 +155,29 @@ def deserialize_bytes(proto_bytes: bytes) -> Plan:
         """
         return Plan(substrait_internal.Serde.deserialize_bytes(proto_bytes))
 
+    @staticmethod
+    def serialize_json(sql: str, ctx: SessionContext, path: str | 
pathlib.Path) -> None:
+        """Serialize a SQL query to a JSON-formatted Substrait plan file.
+
+        Args:
+            sql: SQL query to serialize.
+            ctx: SessionContext to use.
+            path: Path to write the JSON-formatted Substrait plan to.
+        """
+        return substrait_internal.Serde.serialize_json(sql, ctx.ctx, str(path))
+
+    @staticmethod
+    def deserialize_json(path: str | pathlib.Path) -> Plan:
+        """Deserialize a Substrait plan from a JSON file.

Review Comment:
   Following up on my earlier comment if we keep JSON handling on Plan, would 
it make sense for from_json() to accept either a JSON string or a file path? 
That might simplify things instead of having separate helpers on Serde. Curious 
what you think.



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