kosiew opened a new issue, #19841: URL: https://github.com/apache/datafusion/issues/19841
## Problem Currently, DataFusion's struct casting includes a **positional fallback** mechanism that allows casting between structs with completely different field names if the field counts match. This violates DuckDB's semantics and can silently corrupt data. **Example of problematic behavior:** ```rust // This currently succeeds but should fail source: struct<left int, right varchar> target: struct<alpha int, beta varchar> // Positional fallback causes: // left → alpha, right → beta // Despite zero matching field names! ``` ## Current Behavior The implementation in [`validate_struct_compatibility()`](datafusion/common/src/nested_struct.rs) currently allows casting when: - No field name overlap exists AND - Field counts match The casting correctly fails only when there's no overlap **and** counts differ with the error: ``` Cannot cast struct with X fields to Y fields without name overlap; positional mapping is ambiguous ``` ## Proposed Solution Align with **DuckDB's semantics** by requiring at least one matching field name for any struct cast to succeed: 1. **Require name-based matching** — at least one field name must match between source and target 2. **Remove positional fallback** — even when field counts are equal 3. **Clear error message** when no field names match ## Impact - **Breaking change** — Any code relying on positional casting with no name overlap will fail - **Safety improvement** — Prevents silent data corruption from accidental field misalignment - **Consistency** — Aligns with DuckDB's well-designed struct casting semantics and the principle of "at least one field name must match" #19674 [discussion](https://github.com/apache/datafusion/pull/19674#issuecomment-3757969719) -- 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]
