class DuckDB::TableFunction

The DuckDB::TableFunction encapsulates a DuckDB table function.

NOTE: DuckDB::TableFunction is experimental now.

require 'duckdb'

db = DuckDB::Database.new
conn = db.connect

# Low-level API:
tf = DuckDB::TableFunction.new
tf.name = 'my_function'
tf.add_parameter(DuckDB::LogicalType::BIGINT)

tf.bind do |bind_info|
  bind_info.add_result_column('value', DuckDB::LogicalType::BIGINT)
end

tf.execute do |func_info, output|
  # Fill output data...
  0  # Return 0 to signal done
end

conn.register_table_function(tf)

# High-level API (recommended):
tf = DuckDB::TableFunction.create(
  name: 'my_function',
  parameters: [DuckDB::LogicalType::BIGINT],
  columns: { 'value' => DuckDB::LogicalType::BIGINT }
) do |func_info, output|
  # Fill output data...
  0  # Return row count (0 when done)
end