Skip to content

Improve DuckDB::ScalarFunction C API coverage #1122

@suketa

Description

@suketa

Overview

DuckDB::ScalarFunction is missing several features from the DuckDB C API. This issue tracks the full list.


Missing API methods

DuckDB::ScalarFunction

DuckDB::FunctionInfo

New class: DuckDB::ScalarFunction::BindInfo

The bind callback receives a duckdb_bind_info. Scalar-function-specific methods not yet wrapped:

  • set_bind_data(data, destroy_callback)duckdb_scalar_function_set_bind_data
  • set_bind_data_copy(copy_callback)duckdb_scalar_function_set_bind_data_copy
  • get_extra_infoduckdb_scalar_function_bind_get_extra_info
  • get_client_contextduckdb_scalar_function_get_client_context was moved to Implement expression folding API for ScalarFunction bind callback #1192

New class: DuckDB::ScalarFunctionSet -> #1221

Enables registering multiple type overloads under the same function name:

  • DuckDB::ScalarFunctionSet.new(name)duckdb_create_scalar_function_set
  • #add(scalar_function)duckdb_add_scalar_function_to_set
  • Connection#register_scalar_function_set(set)duckdb_register_scalar_function_set

Missing type support in input/output handling

Currently handled: BOOLEAN, TINYINT, UTINYINT, SMALLINT, USMALLINT, INTEGER, UINTEGER, BIGINT, UBIGINT, FLOAT, DOUBLE, VARCHAR, BLOB, TIMESTAMP, DATE, TIME

Missing scalar types (straightforward)

  • HUGEINT, UHUGEINT — use duckdb_hugeint / duckdb_uhugeint struct → Ruby Integer
  • TIMESTAMP_S, TIMESTAMP_MS, TIMESTAMP_NS, TIMESTAMP_TZ — same pattern as TIMESTAMP
  • TIME_TZ
  • TIME_NS — same pattern as TIME move to make DuckDB::ScalarFunction acccept time_ns column #1265
  • INTERVAL — map to/from DuckDB::Interval
  • UUID — stored as hugeint internally, expose as String
  • DECIMAL — needs width/scale metadata from logical type

Missing complex types (harder, lower priority)

  • LIST, STRUCT, MAP, ARRAY, UNION, ENUM — require recursive child vector handling

Note: the same type gaps also exist in DuckDB::DataChunk#set_value used by the table function adapter, so fixing these would benefit both APIs.

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