kosiew commented on code in PR #19955:
URL: https://github.com/apache/datafusion/pull/19955#discussion_r2730326454


##########
docs/source/library-user-guide/upgrading.md:
##########
@@ -118,6 +118,78 @@ let context = SimplifyContext::default()
 
 See [`SimplifyContext` 
documentation](https://docs.rs/datafusion-expr/latest/datafusion_expr/simplify/struct.SimplifyContext.html)
 for more details.
 
+### Struct Casting Now Requires Field Name Overlap
+
+DataFusion's struct casting mechanism previously allowed casting between 
structs with differing field names if the field counts matched. This 
"positional fallback" behavior could silently misalign fields and cause data 
corruption.
+
+**Breaking Change:**
+
+Starting with DataFusion 53.0.0, struct casts now require **at least one 
overlapping field name** between the source and target structs. Casts without 
field name overlap are rejected at plan time with a clear error message.
+
+**Who is affected:**
+
+- Applications that cast between structs with no overlapping field names
+- Queries that rely on positional struct field mapping (e.g., casting 
`struct(x, y)` to `struct(a, b)` based solely on position)
+- Code that constructs or transforms struct columns programmatically
+
+**Migration guide:**
+
+If you encounter an error like:
+
+```text
+Cannot cast struct with 2 fields to 2 fields because there is no field name 
overlap
+```
+
+You must explicitly rename or map fields to ensure at least one field name 
matches. Here are common patterns:
+
+**Example 1: Rename fields in the target schema to match source names**
+
+**Before (would fail now):**
+
+```sql
+-- This would previously succeed by mapping positionally: x→a, y→b
+SELECT CAST(source_col AS STRUCT<a INT, b INT>) FROM table1;
+```
+
+**After (must align names):**
+
+```sql
+-- Explicitly rename to match source field names
+SELECT CAST(source_col AS STRUCT<x INT, y INT>) FROM table1;

Review Comment:
   Amended in 
https://github.com/apache/datafusion/pull/19955/commits/659fc0fe093870057102928f6245243cc192cb35



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