Skip to content

FFI: FFI_SchemaProvider missing table_type cheap-path #22333

@timsaucer

Description

@timsaucer

Gap

FFI_SchemaProvider in datafusion/ffi/src/schema_provider.rs does not plumb SchemaProvider::table_type. Consumer-side ForeignSchemaProvider falls back to the trait default, which calls table() — forcing a full async lookup just to answer a question producers can usually answer cheaply.

Missing method

  • table_type (async, defaulted on the trait)

Why it matters

Severity: important. Queries against information_schema.tables iterate over every table in every schema, asking only for its type. Without the cheap-path, every probe pays an unnecessary FFI hop into table() plus whatever the producer does to materialize a TableProvider. Producers that override table_type to avoid this work see their optimization silently discarded.

Adjacent observation (not part of this issue)

owner_name is currently exposed as a static FFI_Option<SString> snapshot field rather than a function pointer. That works for the common case but cannot reflect dynamic owner changes. Worth a separate discussion if a producer needs the dynamic behavior; this issue is only about table_type.

Implementation notes

  • Plumb table_type as unsafe extern \"C\" fn(...) -> FfiFuture<FFI_Result<FFI_Option<FFI_TableType>>>; wrapper body calls inner.table_type(name).await.
  • Layout change → api change label, target main only, no back-port to branch-<major>.
  • Add unit tests (local-bypass + mock_foreign_marker_id forced-foreign) and integration test under datafusion/ffi/tests/ffi_catalog*.rs covering both the override path and the consumer-side fallback.

Generated from an audit performed for PR #22327 (datafusion-ffi agent skill). If a PR addressing this finds the omission to be a false positive (e.g., a documented reason to keep the async-default path), 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

    catalogRelated to the catalog crateenhancementNew 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