mkleen opened a new pull request, #22730:
URL: https://github.com/apache/datafusion/pull/22730

   ## Which issue does this PR close?
   
   - Closes 
https://github.com/issues/assigned?issue=apache%7Cdatafusion%7C22709.
   
   ## Rationale for this change
   
   The current behavior is expected according to 
https://github.com/apache/datafusion/pull/19674. This pr only improves the 
error message, because the case is already handled. 
   
   ```sql
   > select arrow_cast(struct(10), 'Struct("c0": non-null Int64)');
   Optimizer rule 'simplify_expressions' failed
   caused by
   This feature is not implemented: Unsupported CAST from Struct("c0": Int64) 
to Struct("c0": non-null Int64)
   ```
   
   becomes:
   
   ```sql
   > select arrow_cast(struct(10), 'Struct("c0": non-null Int64)');
   Optimizer rule 'simplify_expressions' failed
   caused by
   Error during planning: Cannot cast nullable struct field 'c0' to 
non-nullable field
   ```
   
   ### Background:
   
   Most SQL implementations treat NULL as a valid value of any type, so a cast 
that removes nullability would be logically inconsistent unless it raises an 
error on NULL input. 
   
   I would say that the cast itself may be valid, but only when an actual NULL 
input in that field raise an error. 
   
   DuckDB structs do not allow to enforce non-nulliable on fields neither 
PostgreSQL composite type fields can have NOT NULL constraints.
   
   See also:
   https://github.com/apache/datafusion/pull/19674#issuecomment-3757589844
   
   ## What changes are included in this PR?
   
   see above.
   
   ## Are these changes tested?
   
   Yes.
   
   ## Are there any user-facing changes?
   
   No.
   


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