cloud-fan opened a new pull request, #59072:
URL: https://github.com/apache/spark/pull/59072
### What changes were proposed in this pull request?
Check whether SQL function option maps are foldable before evaluating them in
`ExprUtils.convertToMapData`. Non-foldable maps now raise the new structured
error
`INVALID_OPTIONS.NON_FOLDABLE`.
This also adds a regression test for `to_csv` with an options map containing
an input column.
### Why are the changes needed?
SQL functions require their options maps to be foldable. Previously,
`ExprUtils.convertToMapData` evaluated a non-foldable `CreateMap` during
analysis. If the map
contained an `AttributeReference`, evaluating it raised `INTERNAL_ERROR`
instead of reporting an
invalid query.
### Does this PR introduce _any_ user-facing change?
Yes. A SQL function called with a non-foldable options map now returns the
analysis error
`INVALID_OPTIONS.NON_FOLDABLE` instead of `INTERNAL_ERROR`. Successfully
analyzed queries are
unchanged.
### How was this patch tested?
Added a regression test to `CsvFunctionsSuite` and ran:
```
build/mvn -pl sql/core -am -Dtest=none \
-DwildcardSuites=org.apache.spark.sql.CsvFunctionsSuite test
```
All 61 tests passed.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-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]