Class SimpleTableProvider

java.lang.Object
org.apache.datafusion.SimpleTableProvider
All Implemented Interfaces:
TableProvider

public final class SimpleTableProvider extends Object implements TableProvider
A TableProvider that pairs a fixed Schema with a function that opens a fresh ArrowReader for each scan. Provided as a convenience for the common case where there is no projection / filter pushdown to implement.

Each call to scan(BufferAllocator) invokes the supplied function and returns whatever ArrowReader it produces, so the function MUST return a fresh, independent reader on every invocation (see the contract on TableProvider.scan(BufferAllocator)).

As TableProvider grows additional methods in the future, this class will provide defaults so existing callers keep working without changes.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleTableProvider(org.apache.arrow.vector.types.pojo.Schema schema, Function<org.apache.arrow.memory.BufferAllocator,org.apache.arrow.vector.ipc.ArrowReader> scanFn)
     
  • 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.
    org.apache.arrow.vector.types.pojo.Schema
    The fixed schema of this table.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleTableProvider

      public SimpleTableProvider(org.apache.arrow.vector.types.pojo.Schema schema, Function<org.apache.arrow.memory.BufferAllocator,org.apache.arrow.vector.ipc.ArrowReader> scanFn)
      Parameters:
      schema - the table schema; returned as-is from schema()
      scanFn - called on every scan(BufferAllocator) with the framework-supplied allocator; must return a fresh, independent ArrowReader each time
  • Method Details

    • schema

      public org.apache.arrow.vector.types.pojo.Schema schema()
      Description copied from interface: TableProvider
      The fixed schema of this table. Called once, at registration time.
      Specified by:
      schema in interface TableProvider
    • scan

      public org.apache.arrow.vector.ipc.ArrowReader scan(org.apache.arrow.memory.BufferAllocator allocator)
      Description copied from interface: TableProvider
      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 TableProvider.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(org.apache.arrow.memory.BufferAllocator, org.apache.datafusion.ScalarFunctionArgs).

      Specified by:
      scan in interface TableProvider