SEPURI-SAI-KRISHNA commented on PR #57931:
URL: https://github.com/apache/spark/pull/57931#issuecomment-5574193194

   @uros-b good question. I checked, and this path is collation-independent. I 
have added a test that asserts it rather than just asserting it here.
   
   `overlay` is not a collation-aware function. `CollationSupport` defines 
collation-aware implementations for 17 operations (`Contains`, `StartsWith`, 
`EndsWith`, `Upper`, `Lower`, `InitCap`, `FindInSet`, `StringInstr`, 
`StringReplace`, `StringLocate`, `SubstringIndex`, `StringTranslate`, the three 
`StringTrim*`, `StringSplitSQL` and `StringInstrWithOccurrence`), and `overlay` 
is not among them. `Overlay.calculate` builds its result purely from character 
positions and `substringSQL`, and the binary overload goes through `ByteArray`, 
so neither consults the collation at any point.
   
   The collation reaches the expression only through `dataType = 
input.dataType`, which propagates the input collation to the result type, and 
this PR does not touch typing. That is not accidental: collation governs 
comparison, ordering and case folding, while this change is integer position 
arithmetic that is clamped before it reaches `substringSQL`.
   
   I have added `SPARK-58713: overlay position arithmetic is 
collation-independent` to `StringExpressionsSuite`. It runs the same 
out-of-range positions fixed by this PR under UTF8_BINARY, UTF8_LCASE, UNICODE 
and UNICODE_CI and asserts identical results. The expected values keep the 
mixed case of `Spark SQL`, which also confirms that nothing is case folded 
under the case-insensitive collations.


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