pub struct TypedTableFunctionBuilder<S: Send + 'static> { /* private fields */ }Expand description
Closure-based builder for table functions with a typed, mutable scan state.
Obtain one via TableFunctionBuilder::with_state or
TableFunctionBuilder::with_bind_init. Set a scan closure with
scan and finish with build to recover a
fully-configured TableFunctionBuilder that can be passed to any
Registrar.
§Example
See the module-level docs for a complete example.
Implementations§
Source§impl<S: Send + 'static> TypedTableFunctionBuilder<S>
impl<S: Send + 'static> TypedTableFunctionBuilder<S>
Sourcepub fn scan<F>(self, f: F) -> Self
pub fn scan<F>(self, f: F) -> Self
Sets the scan closure.
The closure receives a mutable reference to the scan state for the
current execution, plus a DataChunk for the output chunk. It must
fill the chunk with zero or more output rows and set the chunk size via
DataChunk::set_size or a ChunkWriter.
Returning with chunk size zero signals end-of-stream to DuckDB.
Column i of the chunk is the i-th column declared in bind: the
typed builder never enables projection pushdown (and
build refuses a raw builder that had it enabled).
Errors are reported through duckdb_function_set_error and terminate
the scan.
Sourcepub fn param(self, type_id: TypeId) -> Self
pub fn param(self, type_id: TypeId) -> Self
Adds a positional parameter. Delegates to TableFunctionBuilder::param.
Sourcepub fn param_logical(self, logical_type: LogicalType) -> Self
pub fn param_logical(self, logical_type: LogicalType) -> Self
Adds a positional parameter with a complex LogicalType.
Delegates to TableFunctionBuilder::param_logical.
Sourcepub fn named_param(self, name: &str, type_id: TypeId) -> Self
pub fn named_param(self, name: &str, type_id: TypeId) -> Self
Adds a named parameter. Delegates to TableFunctionBuilder::named_param.
Sourcepub fn named_param_logical(self, name: &str, logical_type: LogicalType) -> Self
pub fn named_param_logical(self, name: &str, logical_type: LogicalType) -> Self
Adds a named parameter with a complex LogicalType.
Delegates to TableFunctionBuilder::named_param_logical.
Sourcepub fn build(self) -> Result<TableFunctionBuilder, ExtensionError>
pub fn build(self) -> Result<TableFunctionBuilder, ExtensionError>
Finalises the typed builder into a raw TableFunctionBuilder ready
for registration.
The returned builder has its bind, init, and scan callbacks wired
to closure trampolines, and stores the user closures in extra_info
for the lifetime of the registered function.
The closures are owned by the returned builder’s extra_info: they are
handed to DuckDB on successful registration, and freed when the
builder is dropped otherwise — an unregistered builder does not leak.
§Errors
Returns an error if scan was never called (the bind
closure is always set at construction time), or if
projection_pushdown was
enabled on the raw builder before it was turned into a typed one. The
typed scan closure writes columns in declaration order and cannot learn
the projection, so with pushdown on SELECT b would receive column
a’s values. Switching it off silently would change configuration the
caller asked for, so it is an error instead.