Repository navigation
fix(ffi): forward ScalarUDF propagate_constraints across FFI - #27889
Open
hieuvu0611 wants to merge 1 commit into
Open
hieuvu0611 wants to merge 1 commit into
hieuvu0611 wants to merge 1 commit into
Conversation
Plumb `ScalarUDFImpl::propagate_constraints` through `FFI_ScalarUDF` and `ForeignScalarUDF` using the existing `FFI_Interval` wrapper so producer constraint-propagation overrides survive the FFI boundary instead of falling back to the default `Ok(Some(vec![]))`. Part of apache#22330.
hieuvu0611
force-pushed
the
fix/issue-22330-ffi-propagate-constraints
branch
from
December 3, 2026 04:42
de85329 to
40dd0bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
FFI_ScalarUDFsilently drops producer overrides of defaulted trait methods #22330 (forwardsScalarUDFImpl::propagate_constraintsonly).Rationale for this change
FFI_ScalarUDFdid not carry a function pointer forScalarUDFImpl::propagate_constraints, soForeignScalarUDFfell 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?
pub propagate_constraintsto the end ofFFI_ScalarUDF(afteroutput_orderingto avoid reordering existing#[repr(C)]fields) using the existingFFI_Interval,SVec,FFI_Option, andFFI_Resultwrappers—matching the signature and conventions ofFFI_PhysicalExpr::propagate_constraints.propagate_constraints_fn_wrapper, wire it inFrom<Arc<ScalarUDF>> for FFI_ScalarUDF, and implementScalarUDFImpl::propagate_constraintsonForeignScalarUDF.datafusion/ffi/src/udf/mod.rscovering local-bypass, forced-foreign (mock_foreign_marker_id), multi-input bound tightening in argument order, unbounded endpoints, infeasibleOk(None), error propagation, and defaultOk(Some(vec![]))(AbsFunc).PlacementUDFtest fixture (datafusion/ffi/src/tests/udf_udaf_udwf.rs) and cross-librarycdylibintegration test (datafusion/ffi/integration-tests/tests/cases/udf.rs) to verify the same cases across an actualdlopenFFI boundary.What is the testing strategy for this PR?
cargo test -p datafusion-ffi):udf::tests::test_ffi_udf_propagate_constraints_round_tripandudf::tests::test_round_trip_scalar_udf(131 passed).cdylibintegration tests (cargo test -p datafusion-ffi -p datafusion-ffi-integration-tests --features integration-tests):cases::udf::tests::test_scalar_udf_placement(134 unit + 37 integration tests passed; re-verified locally on Rust1.100.1, full1.99.1matrix covered by fork CI).cargo fmt --all -- --checkandcargo clippy --no-deps -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 fordatafusion-ffitargetingmainonly (no backport).api changelabel? (As an external fork PR, I cannot apply labels directly.)ai-policy.md: AI tooling was used to assist with research and drafting; I have reviewed and verified all changes end-to-end.