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

   ## Which issue does this PR close?
   
   - Part of #22330 (forwards `ScalarUDFImpl::propagate_constraints` only).
   
   ## Rationale for this change
   
   `FFI_ScalarUDF` did not carry a function pointer for 
`ScalarUDFImpl::propagate_constraints`, so `ForeignScalarUDF` fell back to the 
default trait implementation (`Ok(Some(vec![]))`). Any scalar UDF loaded across 
the FFI boundary silently lost producer-defined interval constraint propagation 
during optimization.
   
   ## What changes are included in this PR?
   
   - Append `pub propagate_constraints` to the end of `FFI_ScalarUDF` (after 
`with_updated_config` to avoid reordering existing `#[repr(C)]` fields) using 
the existing `FFI_Interval`, `SVec`, `FFI_Option`, and `FFI_Result` 
wrappers—matching the signature and conventions of 
`FFI_PhysicalExpr::propagate_constraints`.
   - Add `propagate_constraints_fn_wrapper`, wire it in `From<Arc<ScalarUDF>> 
for FFI_ScalarUDF`, and implement `ScalarUDFImpl::propagate_constraints` on 
`ForeignScalarUDF`.
   - Add unit tests in `datafusion/ffi/src/udf/mod.rs` covering local-bypass, 
forced-foreign (`mock_foreign_marker_id`), multi-input bound tightening in 
argument order, unbounded endpoints, infeasible `Ok(None)`, error propagation, 
and default `Ok(Some(vec![]))` (`AbsFunc`).
   - Extend the existing `PlacementUDF` test fixture 
(`datafusion/ffi/src/tests/udf_udaf_udwf.rs`) and cross-library `cdylib` 
integration test (`datafusion/ffi/integration-tests/tests/cases/udf.rs`) to 
verify the same cases across an actual `dlopen` FFI boundary.
   
   ## What is the testing strategy for this PR?
   
   - Unit tests (`cargo test -p datafusion-ffi`): 
`udf::tests::test_ffi_udf_propagate_constraints_round_trip` and 
`udf::tests::test_round_trip_scalar_udf` (128 passed).
   - Cross-library `cdylib` integration tests (`cargo test -p datafusion-ffi -p 
datafusion-ffi-integration-tests --features integration-tests`): 
`cases::udf::tests::test_scalar_udf_placement` (131 unit + 36 integration tests 
passed).
   - Formatting and lints: `cargo fmt --all -- --check` and `cargo clippy -p 
datafusion-ffi -p datafusion-ffi-integration-tests --all-targets --all-features 
-- -D warnings`.
   
   ## Are there any user-facing changes?
   
   Yes — this adds a new field to `#[repr(C)] pub struct FFI_ScalarUDF`, which 
is an ABI/layout break for `datafusion-ffi` targeting `main` only (no backport).
   
   - Request for committers: could you please add the `api change` label? (As 
an external fork PR, I cannot apply labels directly.)
   - Disclosure per `ai-policy.md`: AI tooling was used to assist with research 
and drafting; I have reviewed and verified all changes end-to-end.
   


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