dongjoon-hyun opened a new pull request, #57516:
URL: https://github.com/apache/spark/pull/57516
### What changes were proposed in this pull request?
This PR fixes a correctness issue where `spark.sql` binds 5 or more
positional
parameters in the wrong order. The resolved parameters were collected via
`resolvedParams.values.toSeq` from a `Map` keyed by `_pos_<idx>`, but Scala's
immutable `Map` does not preserve insertion order for 5+ entries. This PR
looks
them up by the positional key instead, in both affected places:
- `classic.SparkSession.sql(sqlText, args: Array[_], tracker)`
- `SparkConnectPlanner.buildParameterContext` (`pos_arguments`)
### Why are the changes needed?
Since Apache Spark 4.1.0 (SPARK-53573), queries with 5+ positional parameters
silently return wrong results in both the classic API and Spark Connect.
```scala
spark.sql("SELECT ?, ?, ?, ?, ?, ?", Array(1, 2, 3, 4, 5, 6)).collect()
// Before: [6,2,5,3,4,1]
// After: [1,2,3,4,5,6]
```
### Does this PR introduce _any_ user-facing change?
Yes, this is a bug fix of the released versions 4.1.0, 4.1.1, and 4.2.0.
### How was this patch tested?
Pass the CIs with the newly added test case.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 5
--
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]