Linhong Liu created SPARK-61579:
-----------------------------------
Summary: Read/write-side CHAR/VARCHAR processing drops a nested
NOT NULL field when rebuilding a struct
Key: SPARK-61579
URL: https://issues.apache.org/jira/browse/SPARK-61579
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 5.0.0
Reporter: Linhong Liu
CharVarcharUtils.processStringForCharVarchar rebuilds a struct containing 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 (e.g. STRUCT<c CHAR(2), z STRING NOT NULL>) is lost in the
rebuilt type. The re-typed attribute is then wider than the original, which
e.g. makes a Delta MERGE type check reject the assignment.
Fix: preserve each field's declared nullability when rebuilding the struct
(wrap declared NOT NULL fields in KnownNotNull); the whole-struct-null case is
still handled by the surrounding null guard. Found via correctness analysis.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]