voonhous opened a new pull request, #20458:
URL: https://github.com/apache/hudi/pull/20458

   ### Describe the issue this Pull Request addresses
   
   Refs #19445 (split out of #19475)
   
   On Spark 4 `StringType` carries a collation. `isCastPreservingOrdering` 
matched `String <-> Numeric` against the `StringType` companion, which only 
equals the default collation, so every cast involving a collated string fell 
through to `case _ => true`. A cast to another collation changes the sort 
order: stats `["B", "a"]` are in UTF8_BINARY order, but `CAST(b AS STRING 
COLLATE UTF8_LCASE) = 'a'` translates to `"B" <= "a"` in UTF8_LCASE, which is 
false, so a file holding `"a"` is pruned.
   
   ### Summary and Changelog
   
   - `HoodieSparkTypeUtils.isCastPreservingOrdering`: the `String <-> Numeric` 
arms match by type, so collated strings are rejected too; `string -> string` 
casts require an identical `StringType`. On Spark 3 `StringType` is a 
singleton, so nothing changes there.
   - Tests: `TestHoodieCatalystExpressionUtils` covers collation-changing, 
collated-to-numeric and collation-preserving casts; `TestDataSkippingUtils` 
adds the repro above. Both are skipped on Spark 3 profiles, since collation 
APIs only exist on Spark 4.
   
   ### Impact
   
   No public API change. Filters over collation-changing casts no longer prune. 
Spark 4 `StringType` equality also compares the char/varchar length constraint, 
so casts between `CHAR`/`VARCHAR` and `STRING` (seen only with 
`spark.sql.preserveCharVarcharTypeInfo`) also stop pruning.
   
   ### Risk Level
   
   low. Every newly rejected cast falls back to no pruning.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


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

Reply via email to