Skip to content

FFI: FFI_TableProvider silently drops producer overrides of defaulted trait methods #22328

@timsaucer

Description

@timsaucer

Gap

FFI_TableProvider in datafusion/ffi/src/table_provider.rs does not plumb several defaulted methods of TableProvider. When a producer overrides one of these, the consumer-side ForeignTableProvider falls back to the trait default, silently losing the override.

Missing methods

  • constraints
  • get_table_definition
  • get_logical_plan
  • get_column_default
  • scan_with_args
  • statistics
  • delete_from
  • update
  • truncate

Why it matters

Severity: critical. The three DML methods (delete_from, update, truncate) silently demote a writable foreign table to read-only. statistics and constraints break cost-based optimization. get_logical_plan / get_table_definition / get_column_default break view + DDL features.

Implementation notes

  • Per the FFI skill: plumb every defaulted method as a plain unsafe extern \"C\" fn. The wrapper body calls inner.method(...) and Arc<dyn TableProvider> dynamic dispatch picks override-or-default for free. Do not use Option<fn> unless there is a corresponding constructor capability flag.
  • This is an FFI_X struct layout change. PR must:
    • Carry the api change label.
    • Target main only — not back-portable to branch-<major>.
    • Add unit tests (local-bypass + forced-foreign via mock_foreign_marker_id).
    • Add integration tests under datafusion/ffi/tests/ exercising the new methods through the cdylib (cargo test -p datafusion-ffi --features integration-tests).

Generated from an audit performed for PR #22327 (datafusion-ffi agent skill). If a PR addressing this finds any item to be a false positive (e.g., a method intentionally omitted for a documented reason), please also propose an update to the datafusion-ffi skill so future audits do not re-flag it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestffiChanges to the ffi crate

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions