class DuckDB::TableFunction::InitInfo
The DuckDB::TableFunction::InitInfo provides context during table function initialization.
It is passed to the init callback to set up execution state.
Example:
table_function.init do |init_info| # Initialize execution state # Can report errors if initialization fails init_info.set_error('Initialization failed') end
rubocop:disable Lint/EmptyClass
Public Instance Methods
Source
static VALUE table_function_init_info_column_count(VALUE self) {
rubyDuckDBInitInfo *ctx;
TypedData_Get_Struct(self, rubyDuckDBInitInfo, &init_info_data_type, ctx);
return ULL2NUM(duckdb_init_get_column_count(ctx->info));
}
Returns the number of projected result columns for this scan. Without projection pushdown this equals the number of result columns added in the bind callback.
init_info.column_count # => 2
Sets the maximum number of threads that can execute the table function concurrently. This is a hint to DuckDB’s scheduler; the actual number of threads is also bounded by the configured worker pool size (e.g., +SET threads+).
init_info.max_threads = 4
Source
static VALUE table_function_init_info_set_error(VALUE self, VALUE error) {
rubyDuckDBInitInfo *ctx;
const char *error_msg;
TypedData_Get_Struct(self, rubyDuckDBInitInfo, &init_info_data_type, ctx);
error_msg = StringValueCStr(error);
duckdb_init_set_error(ctx->info, error_msg);
return self;
}
Sets an error message for the init phase. This will cause the query to fail with the specified error.
init_info.set_error('Invalid initialization')
Source
static VALUE table_function_init_info_set_max_threads(VALUE self, VALUE max_threads) {
rubyDuckDBInitInfo *ctx;
TypedData_Get_Struct(self, rubyDuckDBInitInfo, &init_info_data_type, ctx);
duckdb_init_set_max_threads(ctx->info, NUM2ULL(max_threads));
return self;
}
Sets the maximum number of threads that can execute the table function concurrently. This is a hint to DuckDB’s scheduler; the actual number of threads is also bounded by the configured worker pool size (e.g., +SET threads+).
init_info.max_threads = 4