You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2026/04/01 00:55:11 UTC

Re: [PR] [SPARK-56253][PYTHON][CONNECT] Make spark.read.json accept DataFrame input [spark]

zhengruifeng commented on code in PR #55097:
URL: https://github.com/apache/spark/pull/55097#discussion_r3019184883


##########
python/pyspark/sql/readwriter.py:
##########
@@ -486,12 +504,20 @@ def func(iterator: Iterable) -> Iterable:
             assert self._spark._jvm is not None
             jrdd = keyed._jrdd.map(self._spark._jvm.BytesToString())
             return self._df(self._jreader.json(jrdd))
+
+        from pyspark.sql.dataframe import DataFrame
+
+        if isinstance(path, DataFrame):
+            assert self._spark._jvm is not None
+            string_encoder = self._spark._jvm.Encoders.STRING()
+            jdataset = getattr(path._jdf, "as")(string_encoder)

Review Comment:
   I think it can simplify the python side callsite a bit.
   another trivial benefit is to reduce the number of py4j calls.



-- 
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-unsubscribe@spark.apache.org

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


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