Sean-Kenneth-Doherty opened a new pull request, #22297:
URL: https://github.com/apache/datafusion/pull/22297

   ## Which issue does this PR close?
   
   - Closes #22226.
   
   ## Rationale for this change
   
   `arrow_cast(NULL, 'FixedSizeBinary(-1)')` currently parses the type string 
successfully and can later panic in Arrow buffer allocation with a 
`LayoutError`. DataFusion should reject that invalid Arrow type specification 
before planning/simplification rewrites the function into a cast.
   
   ## What changes are included in this PR?
   
   - Adds shared `arrow_cast` type parsing/validation after Arrow `DataType` 
parsing.
   - Rejects negative `FixedSizeBinary` element lengths with a DataFusion 
execution error.
   - Reuses the same validation for `arrow_try_cast` so return-field planning 
and simplify-time rewrites agree.
   - Checks nested types too, so `List(FixedSizeBinary(-1))` is rejected before 
it reaches execution.
   - Adds SQL logic regressions for `arrow_cast`, `arrow_try_cast`, and nested 
`FixedSizeBinary(-1)`.
   
   ## Are these changes tested?
   
   Yes.
   
   - `cargo test -p datafusion-functions arrow_cast` (compiled successfully; no 
tests matched the filter)
   - `cargo test -p datafusion-sqllogictest --test sqllogictests -- 
arrow_typeof.slt`
   - `cargo test -p datafusion-functions`
   - `cargo fmt --check`
   - `cargo clippy -p datafusion-functions --all-targets -- -D warnings`
   - `git diff --check`
   
   ## Are there any user-facing changes?
   
   Yes. Invalid `FixedSizeBinary(-1)` type specs passed to `arrow_cast` / 
`arrow_try_cast` now return a normal DataFusion execution error instead of 
allowing a later panic.
   


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