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

   ## Which issue does this PR close?
   
   - Part of #22330 (the `output_ordering` slice).
   
   ## Rationale for this change
   
   `ForeignScalarUDF` does not forward `output_ordering`, so the consumer side 
uses the trait default. The default derives the ordering from 
`preserves_lex_ordering`, which is already forwarded, but a producer that 
overrides `output_ordering` itself (for example, a function that reverses the 
input order, like negation) loses the override across the FFI boundary. The 
consumer then reports a wrong output ordering for the function.
   
   ## What changes are included in this PR?
   
   - `FFI_ScalarUDF` gets an `output_ordering` function pointer. It takes the 
input `FFI_ExprProperties` and returns `FFI_SortProperties`, which already 
exist in `datafusion_ffi::expr::expr_properties`.
   - `ForeignScalarUDF::output_ordering` calls it, so the producer's override 
(or the default, when the producer does not override it) runs on the producer 
side.
   
   ## What is the testing strategy for this PR?
   
   - New unit test `test_ffi_udf_output_ordering_round_trip` in 
`datafusion/ffi/src/udf/mod.rs`. The test UDF reverses the order of its single 
input, which differs from the default, and returns an error for other inputs. 
The test checks `Ordered`, `Singleton`, `Unordered` and the error case on the 
local bypass path and on the forced foreign path (`mock_foreign_marker_id`). 
The forced foreign case fails on `main`.
   - The test UDF in the FFI test library gets the same override, and 
`test_scalar_udf_placement` in the integration tests checks it across the 
dynamic library boundary.
   
   Commands run:
   
   - `cargo test -p datafusion-ffi -p datafusion-ffi-integration-tests –lib 
–tests –features integration-tests`: passed
   - `cargo clippy -p datafusion-ffi -p datafusion-ffi-integration-tests 
–all-targets –all-features – -D warnings`: passed
   - `cargo fmt –all – –check`: passed
   
   Fork CI: 
[Rust](https://github.com/tlfua/datafusion/actions/runs/46276250918), 
[Dev](https://github.com/tlfua/datafusion/actions/runs/46276250898), 
[Dependencies](https://github.com/tlfua/datafusion/actions/runs/46276250895)
   
   ## Are there any user-facing changes?
   
   Yes. Adding a field to `FFI_ScalarUDF` changes its layout, so this is an FFI 
ABI break: foreign libraries must be rebuilt against the new DataFusion 
version. This needs the `api change` label and should not be back-ported to a 
release branch.
   


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