linhongliu-db opened a new pull request, #60420:
URL: https://github.com/apache/spark/pull/60420

   ### What changes were proposed in this pull request?
   
   `CharVarcharUtils.processStringForCharVarchar` rebuilds a struct that 
contains a CHAR/VARCHAR field
   as a `named_struct` of `GetStructField(expr, i)` values. Because the struct 
`expr` is nullable, every
   `GetStructField` is nullable, so a declared nested NOT NULL (for example
   `STRUCT<c CHAR(2), z STRING NOT NULL>`) is dropped from the rebuilt type. 
The re-typed attribute is
   then wider than the original, which (for example) makes a Delta MERGE type 
check reject the
   assignment.
   
   This PR preserves each field's declared nullability when rebuilding the 
struct (wrapping declared
   NOT NULL fields in `KnownNotNull`); the whole-struct-null case is still 
handled by the surrounding
   `nullSafeRebuiltStruct` guard, and the "no field needs processing" shortcut 
is kept.
   
   ### Why are the changes needed?
   
   A nested NOT NULL constraint is silently lost after read/write-side 
CHAR/VARCHAR processing.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No behavioral change for query results; the rebuilt struct type now keeps 
nested NOT NULL as
   declared, matching the source schema.
   
   ### How was this patch tested?
   
   New `CharVarcharTestSuite` unit test asserting a nested NOT NULL field 
survives the struct rebuild
   (previously every rebuilt field became nullable). Locally 
`CharVarcharTestSuite` (192 tests) passes
   and scalastyle is clean on JDK 21.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Isaac)
   
   This pull request and its description were written by Isaac.
   


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