zhengruifeng commented on code in PR #47411:
URL: https://github.com/apache/spark/pull/47411#discussion_r1683948173
##########
python/pyspark/ml/util.py:
##########
@@ -464,7 +464,10 @@ def saveMetadata(
metadataJson = DefaultParamsWriter._get_metadata_to_save(
instance, sc, extraMetadata, paramMap
)
- sc.parallelize([metadataJson], 1).saveAsTextFile(metadataPath)
+ spark = SparkSession.getActiveSession()
+ spark.createDataFrame([(metadataJson,)],
schema=["value"]).repartition(1).write.text(
Review Comment:
I just checked that pyspark classic (which is built atop `LogicalRDD`) need
repartition to make sure single partition;
while pyspark connect doesn't need this, since it uses `LocalRelation`.
Probably in this case we can use `coalesce(1)` instead to avoid shuffle.
--
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]