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

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: 
https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a 
faster review.
     7. If you want to add a new configuration, please read the guideline first 
for naming configurations in
        
'common/utils/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the 
guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   
   [SPARK-59016](https://issues.apache.org/jira/browse/SPARK-59016) (parent 
[SPARK-58794](https://issues.apache.org/jira/browse/SPARK-58794)).
   
   Follow-up on first-class CHAR/VARCHAR 
(`spark.sql.charVarchar.standardSemantics.enabled`):
   
   - `SimplifyCasts` keeps `CAST(... AS STRING)` when the child is first-class 
CHAR/VARCHAR, not only when it is annotated STRING (flag off). Those casts are 
a type change, not a no-op.
   - `PushDownUtils.toOutputAttrs` no longer rewrites CHAR/VARCHAR to annotated 
STRING when standard semantics are on, so V2 column prune keeps the logical 
types.
   - The FunctionRegistry leak inventory covers extra arities and nested 
array/map/struct shapes. True pass-throughs (`flatten`, `map_concat`, 
`map_entries`, `map_keys`, `map_values`, `nvl2`) are allowlisted.
   
   ### Why are the changes needed?
   
   With first-class types, `CharType`/`VarcharType` are subclasses of 
`StringType` but are not unconstrained STRING. Dropping `CAST(c AS STRING)` or 
stripping length in V2 scan output hides that distinction. The previous 
inventory only used seven argument templates, so a leak at another arity or 
nested shape would not fail CI.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, only when `spark.sql.charVarchar.standardSemantics.enabled` is true 
(still off by default).
   
   - `CAST(char_or_varchar AS STRING)` stays in the optimized plan.
   - V2 scans that prune columns keep CHAR/VARCHAR in the output schema instead 
of annotated STRING.
   
   ### How was this patch tested?
   
   - `catalyst/testOnly 
org.apache.spark.sql.catalyst.optimizer.SimplifyCastsSuite -- -z SPARK-59016`
   - `sql/testOnly org.apache.spark.sql.BasicCharVarcharTestSuite -- -z 
inventoried`
   - `sql/testOnly org.apache.spark.sql.DSV2CharVarcharTestSuite -- -z prune`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Cursor Grok 4.6
   


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