srielau opened a new pull request, #58130:
URL: https://github.com/apache/spark/pull/58130

   ### What changes were proposed in this pull request?
   
   **Depends on #58087** (language surfaces), which depends on #58080 / #58033. 
Please review/merge those first; rebase this onto `master` afterward. Delta vs 
follow-up: 
https://github.com/srielau/spark/compare/SPARK-58794-surfaces...serge-rielau_data/SPARK-58794-r1-implicit
   
   Under `spark.sql.charVarchar.standardSemantics.enabled`, R1 (transforming 
string operators return unbounded `STRING`) is implemented by promoting 
`CHAR`/`VARCHAR` to unbounded `STRING` at call sites that expect a plain 
string, the same way `SHORT` is promoted to `INT`.
   
   - Move `charVarcharToPlainString` onto `TypeCoercionHelper` and recurse into 
arrays when the expected type is `AbstractArrayType` / `TypeCollection` (e.g. 
`array_join`).
   - Apply that promotion in `ImplicitTypeCasts` for `ImplicitCastInputTypes` 
and `ExpectsInputTypes`.
   - Use collation-preserving `implicitCastToString` for `Concat` / `Elt` 
instead of `implicitCast(e, StringType)` (which missed collated CHAR).
   - Drop per-expression `transformingStringResultType` stripping; result type 
follows the (promoted) child.
   - Mix `ImplicitCastInputTypes` into `JsonTuple` and `StringSplitSQL` so they 
get the same promotion.
   
   ### Why are the changes needed?
   
   R1 belongs in the analyzer, not in every expression's `dataType`. Per-expr 
stripping missed `ExpectsInputTypes` (e.g. `str_to_map`, `array_join`) and 
collated CHAR on `Concat`. Promotion at the call site is the same pattern as 
numeric widening.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, when the flag is on: transforming string operators insert `CAST(... AS 
STRING)` in analyzed plans and return unbounded `STRING`. Result values are 
unchanged versus the previous per-expr strip.
   
   ### How was this patch tested?
   
   - `TypeCoercionSuite` (Concat CHAR->STRING; ImplicitTypeCasts 
Upper(CharType))
   - `BasicCharVarcharTestSuite` (R1 analyzed-plan asserts for Upper / Concat / 
ArrayJoin / StringToMap)
   - Regenerated `charvarchar-standard-semantics.sql` analyzer goldens
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes (Cursor).


-- 
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]

Reply via email to