Interface TableProvider
- All Known Implementing Classes:
SimpleTableProvider
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 ClassesModifier and TypeInterfaceDescriptionstatic enumDataFusion's per-filter pushdown contract. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.arrow.vector.ipc.ArrowReaderscan(org.apache.arrow.memory.BufferAllocator allocator) Open a fresh batch stream for this table.default ExecutionPlanscanWithArgs(ScanArgs args) Plan one bounded scan without opening its reader.org.apache.arrow.vector.types.pojo.Schemaschema()The fixed schema of this table.default List<TableProvider.FilterPushdown> 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 ALLover the same table, etc.).Each invocation MUST return an independent
ArrowReader. The reader's schema MUST equalschema(). The reader's buffers MUST be allocated fromallocator(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 onScalarFunction.evaluate(BufferAllocator, ScalarFunctionArgs). -
scanWithArgs
Plan one bounded scan without opening its reader. The default defers toscan(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.
-