zhengruifeng opened a new pull request, #44177: URL: https://github.com/apache/spark/pull/44177
### What changes were proposed in this pull request? Make `DataFrame.withColumnsRenamed` respect the dict ordering ### Why are the changes needed? the ordering in `withColumnsRenamed` matters scala ``` scala> val df = spark.range(1000) val df: org.apache.spark.sql.Dataset[Long] = [id: bigint] scala> df.withColumnsRenamed(Map("id" -> "a", "a" -> "b")) val res0: org.apache.spark.sql.DataFrame = [b: bigint] scala> df.withColumnsRenamed(Map("a" -> "b", "id" -> "a")) val res1: org.apache.spark.sql.DataFrame = [a: bigint] ``` ### Does this PR introduce _any_ user-facing change? yes before this PR ``` In [1]: df = spark.range(10) In [2]: df.withColumnsRenamed({"id": "a", "a": "b"}) Out[2]: DataFrame[a: bigint] In [3]: df.withColumnsRenamed({"a": "b", "id": "a"}) Out[3]: DataFrame[a: bigint] ``` after this PR ``` In [1]: df = spark.range(10) In [2]: df.withColumnsRenamed({"id": "a", "a": "b"}) Out[2]: DataFrame[b: bigint] In [3]: df.withColumnsRenamed({"a": "b", "id": "a"}) Out[3]: DataFrame[a: bigint] ``` ### How was this patch tested? added ut ### Was this patch authored or co-authored using generative AI tooling? no -- 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