Skip to content

Improve DuckDB::TableFunction C API coverage #1123

@suketa

Description

@suketa

Overview

DuckDB::TableFunction and its related classes (BindInfo, InitInfo, FunctionInfo) are missing several features from the DuckDB C API. This issue tracks the full list.


Currently implemented

Class Methods
TableFunction name=, add_parameter, add_named_parameter, bind, init, execute
BindInfo parameter_count, get_parameter, get_named_parameter, add_result_column, set_cardinality, set_error
InitInfo set_error
FunctionInfo set_error

Missing from DuckDB::TableFunction

  • local_init(&block) — wrap duckdb_table_function_set_local_init. Enables per-thread local initialization for parallel execution.
  • supports_projection_pushdown(bool) — wrap duckdb_table_function_supports_projection_pushdown. Tells DuckDB the function can skip columns not needed by the query.

Missing from DuckDB::BindInfo

  • get_extra_info — wrap duckdb_bind_get_extra_info. Retrieve extra info set on the function via set_extra_info.
  • set_bind_data(data, destroy) — wrap duckdb_bind_set_bind_data. Store user data during bind phase for use in init/execute callbacks.
  • get_client_context — wrap duckdb_table_function_get_client_context. Provides access to the client connection context during bind.

Missing from DuckDB::InitInfo

  • get_extra_info — wrap duckdb_init_get_extra_info. Retrieve extra info set on the function.
  • get_bind_data — wrap duckdb_init_get_bind_data. Access data stored during the bind phase.
  • set_init_data(data, destroy) — wrap duckdb_init_set_init_data. Store init state for use in the execute callback.
  • column_count — wrap duckdb_init_get_column_count. Number of columns DuckDB actually needs (for projection pushdown).
  • column_index(i) — wrap duckdb_init_get_column_index. Which column index DuckDB needs (for projection pushdown).
  • set_max_threads(n) — wrap duckdb_init_set_max_threads. Controls parallelism for table function execution.

Missing from DuckDB::FunctionInfo

  • get_bind_data — wrap duckdb_function_get_bind_data. Access bind-phase user data in the execute callback.
  • get_init_data — wrap duckdb_function_get_init_data. Access init-phase data in the execute callback.
  • get_local_init_data — wrap duckdb_function_get_local_init_data. Access per-thread local init data in the execute callback (parallel execution).

Priority notes

  • BindInfo#set_bind_data + FunctionInfo#get_bind_data — highest value; enables stateful functions that compute schema dynamically at bind time and pass state to execute
  • Projection pushdown (supports_projection_pushdown + InitInfo#column_count / column_index) — significant performance feature for large tables; allows skipping unneeded columns entirely
  • local_init + get_local_init_data — needed for correct parallel execution support

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions