dongjoon-hyun commented on code in PR #47347: URL: https://github.com/apache/spark/pull/47347#discussion_r1678140089
########## mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala: ########## @@ -411,7 +411,10 @@ private[ml] object DefaultParamsWriter { paramMap: Option[JValue] = None): Unit = { val metadataPath = new Path(path, "metadata").toString val metadataJson = getMetadataToSave(instance, sc, extraMetadata, paramMap) - sc.parallelize(Seq(metadataJson), 1).saveAsTextFile(metadataPath) + val spark = SparkSession.builder().sparkContext(sc).getOrCreate() + // Note that we should write single file. If there are more than one row + // it produces more partitions. + spark.createDataFrame(Seq(Tuple1(metadataJson))).write.text(metadataPath) Review Comment: It seems that the previous code did not have `repartition(1)`. > This PR proposes to remove repartition(1) when writing metadata in ML/MLlib. It already writes one file. Maybe, I missed the context. Does the existing code generate multiple file, @HyukjinKwon ? > sc.parallelize(Seq(metadataJson), 1).saveAsTextFile(metadataPath) -- 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