I use coalesce(1) to write a Dataframe to single file, like this.
df.coalesce(1).write.format("csv")
.option("header", true).mode("overwrite").save(output_path)
A quick glance at the file shows that the order was preserved, but is it always the case? If the order is not preserved, how can I enforce it? The coalesce function of RDD has an extra parameter to disallow shuffling, but the coalesce method of Dataframe only takes 1 parameter.