Interface TableProvider

All Known Implementing Classes:
SimpleTableProvider

public interface TableProvider
A Java-implemented table that can be registered with a SessionContext via SessionContext.registerTable(String, TableProvider). Mirrors the role of DataFusion's Rust TableProvider trait. Implement scan(BufferAllocator) for full-schema reads. Optionally override scanWithArgs(ScanArgs) to plan a lazy scan with projection/filter/limit pushdown.

SimpleTableProvider is a ready-made implementation for the common case of "I have a schema and a function that returns an ArrowReader".

Each execution must return a fresh, independent ArrowReader so that queries which touch the table more than once (self-joins, UNION ALL, repeated reads) work correctly. The returned reader is closed by the framework when the stream ends.

The schema returned by schema() is captured once at registration time. Every batch produced by scan(BufferAllocator) must conform to it. A plan returned by scanWithArgs(ScanArgs) may instead produce the requested projected schema.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    DataFusion's per-filter pushdown contract.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.arrow.vector.ipc.ArrowReader
    scan(org.apache.arrow.memory.BufferAllocator allocator)
    Open a fresh batch stream for this table.
    Plan one bounded scan without opening its reader.
    org.apache.arrow.vector.types.pojo.Schema
    The fixed schema of this table.
    supportsFiltersPushdown(List<org.apache.datafusion.protobuf.LogicalExprNode> filters)
    Return one capability per input filter, in the same order.
  • Method Details

    • schema

      org.apache.arrow.vector.types.pojo.Schema schema()
      The fixed schema of this table. Called once, at registration time.
    • scan

      org.apache.arrow.vector.ipc.ArrowReader scan(org.apache.arrow.memory.BufferAllocator allocator)
      Open a fresh batch stream for this table. Called once per physical scan of the table — a single query may invoke this more than once (self-joins, UNION ALL over the same table, etc.).

      Each invocation MUST return an independent ArrowReader. The reader's schema MUST equal schema(). The reader's buffers MUST be allocated from allocator (or from a child of it) — the framework needs the reader's allocator hierarchy to share a root with the one it passes here. The allocator contract mirrors the one on ScalarFunction.evaluate(BufferAllocator, ScalarFunctionArgs).

    • scanWithArgs

      default ExecutionPlan scanWithArgs(ScanArgs args)
      Plan one bounded scan without opening its reader. The default defers to scan(BufferAllocator) at execution time, preserving existing providers.

      Only supported/inexact filters are included in args. The plan may produce either the registered full schema or exactly the requested projection, including zero-column batches that preserve row counts. The native adapter projects full-schema batches when needed.

      Planning may be repeated and must not read source rows. Callbacks may run on native worker threads; shared provider state and reader factories must be thread-safe.

    • supportsFiltersPushdown

      default List<TableProvider.FilterPushdown> supportsFiltersPushdown(List<org.apache.datafusion.protobuf.LogicalExprNode> filters)
      Return one capability per input filter, in the same order. The default declines every filter. An inexact filter must never discard a matching row. Expressions are generated protobuf messages; source-specific access-path decisions remain in the provider.