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


##########
python/tests/test_substrait.py:
##########
@@ -74,3 +74,48 @@ def test_substrait_file_serialization(ctx, tmp_path, 
path_to_str):
     expected_actual_plan = ss.Consumer.from_substrait_plan(ctx, actual_plan)
 
     assert str(expected_logical_plan) == str(expected_actual_plan)
+
+def test_substrait_plan_to_from_json(ctx):
+    # Create a simple plan
+    sql = "SELECT * FROM t"
+    batch = pa.RecordBatch.from_arrays(
+        [pa.array([1, 2, 3]), pa.array([4, 5, 6])],
+        names=["a", "b"],
+    )
+    ctx.register_record_batches("t", [[batch]])
+
+    # Serialize to plan
+    plan = ss.Serde.serialize_to_plan(sql, ctx)
+
+    # Convert plan to JSON
+    json_str = plan.to_json()
+    assert isinstance(json_str, str)
+    assert "relations" in json_str  # basic sanity check

Review Comment:
   Hi @timsaucer,
   
   I was able to generate a JSON-formatted Substrait plan using my DataFusion 
implementation. Comparing it with Isthmus:
   
   - Both include relations, project expressions, virtualTable values, and 
correct column mappings.
   - Minor differences exist: DataFusion uses i64 instead of i32, column names 
differ, and optional metadata (extensions, typeAliases) are not included — 
these do not affect compatibility. 
   - DuckDB currently does not provide a working JSON inspection method due to 
extension availability issues, so direct JSON comparison via DuckDB isn’t 
possible.
   
   Overall, the DataFusion output is compatible and can be used for 
reproducibility and validation.



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