Skip to content

FFI: plumb with_updated_config for FFI_ScalarUDF#22797

Open
Amogh-2404 wants to merge 1 commit into
apache:mainfrom
Amogh-2404:fix/issue-22330-ffi-with-updated-config
Open

FFI: plumb with_updated_config for FFI_ScalarUDF#22797
Amogh-2404 wants to merge 1 commit into
apache:mainfrom
Amogh-2404:fix/issue-22330-ffi-with-updated-config

Conversation

@Amogh-2404
Copy link
Copy Markdown
Contributor

Which issue does this close?

Part of #22330.

Rationale for this change

FFI_ScalarUDF doesn't plumb with_updated_config, so a provider that overrides it has the override silently dropped across the FFI boundary — the consumer falls back to the trait default (None). Continues the method-coverage work started with placement (#22608).

What changes are included in this PR?

  • Adds a with_updated_config fn pointer to FFI_ScalarUDF plus the wrapper and forwarding on both sides. Config crosses in via the existing FFI_ConfigOptions; the reconfigured UDF comes back as FFI_Option<FFI_ScalarUDF>.
  • A forced-foreign unit test and a cross-cdylib integration test, both asserting the override survives the boundary.

Adding the field changes the #[repr(C)] layout, so this is an ABI change.

Are these changes tested?

Yes — cargo test -p datafusion-ffi --features integration-tests.

Are there any user-facing changes?

ABI change for FFI consumers (recompile required). No SQL-level changes.

part of apache#22330. adds the `with_updated_config` fn pointer so a provider's
override survives the FFI boundary instead of silently falling back to the
trait default (None) on the consumer side. the config crosses in via the
existing FFI_ConfigOptions and the reconfigured udf comes back as
FFI_Option<FFI_ScalarUDF>.

covered by a forced-foreign unit test and a cross-cdylib integration test
that both assert the override crosses.
@github-actions github-actions Bot added the ffi Changes to the ffi crate label Jun 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 7, 2026

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion-ffi v53.1.0 (current)
       Built [  64.006s] (current)
     Parsing datafusion-ffi v53.1.0 (current)
      Parsed [   0.065s] (current)
    Building datafusion-ffi v53.1.0 (baseline)
       Built [  60.087s] (baseline)
     Parsing datafusion-ffi v53.1.0 (baseline)
      Parsed [   0.064s] (baseline)
    Checking datafusion-ffi v53.1.0 -> v53.1.0 (no change; assume patch)
     Checked [   0.359s] 223 checks: 221 pass, 1 fail, 1 warn, 30 skip

--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field FFI_ScalarUDF.with_updated_config in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/udf/mod.rs:99
  field ForeignLibraryModule.create_with_config_udf in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:94

--- warning repr_c_plain_struct_fields_reordered: struct fields reordered in repr(C) struct ---

Description:
A public repr(C) struct had its fields reordered. This can change the struct's memory layout, possibly breaking FFI use cases that depend on field position and order.
        ref: https://doc.rust-lang.org/reference/type-layout.html#reprc-structs
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/repr_c_plain_struct_fields_reordered.ron

Failed in:
  FFI_ScalarUDF.clone moved from position 8 to 9, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/udf/mod.rs:107
  FFI_ScalarUDF.release moved from position 9 to 10, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/udf/mod.rs:110
  FFI_ScalarUDF.private_data moved from position 10 to 11, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/udf/mod.rs:114
  FFI_ScalarUDF.library_marker_id moved from position 11 to 12, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/udf/mod.rs:119
  ForeignLibraryModule.create_table_function moved from position 8 to 9, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:96
  ForeignLibraryModule.create_sum_udaf moved from position 9 to 10, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:100
  ForeignLibraryModule.create_stddev_udaf moved from position 10 to 11, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:103
  ForeignLibraryModule.create_rank_udwf moved from position 11 to 12, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:105
  ForeignLibraryModule.create_extension_options moved from position 12 to 13, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:108
  ForeignLibraryModule.create_empty_exec moved from position 13 to 14, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:110
  ForeignLibraryModule.create_exec_with_statistics moved from position 14 to 15, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:112
  ForeignLibraryModule.create_table_with_statistics moved from position 15 to 16, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:114
  ForeignLibraryModule.create_physical_optimizer_rule moved from position 16 to 17, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:117
  ForeignLibraryModule.create_context_aware_optimizer_rule moved from position 17 to 18, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:119
  ForeignLibraryModule.version moved from position 18 to 19, in /home/runner/work/datafusion/datafusion/datafusion/ffi/src/tests/mod.rs:121

     Summary semver requires new major version: 1 major and 0 minor checks failed
     Warning produced 1 major and 0 minor level warnings
    Finished [ 127.090s] datafusion-ffi

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change ffi Changes to the ffi crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant