class DuckDB::AggregateFunction
DuckDB::AggregateFunction encapsulates DuckDB’s aggregate function.
@note DuckDB::AggregateFunction is experimental. Phase 1.0 only supports
+set_init+ and +set_finalize+; +update+ and +combine+ are internal no-ops.
Public Class Methods
Source
static VALUE aggregate_function_state_registry_size(VALUE klass) {
(void)klass;
return LONG2NUM((long)RHASH_SIZE(g_aggregate_state_registry));
}
Returns the number of Ruby states currently tracked in the registry.
Source
static VALUE duckdb_aggregate_function_initialize(VALUE self) {
rubyDuckDBAggregateFunction *p;
TypedData_Get_Struct(self, rubyDuckDBAggregateFunction, &aggregate_function_data_type, p);
p->aggregate_function = duckdb_create_aggregate_function();
p->init_proc = Qnil;
p->update_proc = Qnil;
p->combine_proc = Qnil;
p->finalize_proc = Qnil;
p->special_handling = false;
return self;
}
Public Instance Methods
Source
# File lib/duckdb/aggregate_function.rb, line 27 def add_parameter(logical_type) logical_type = check_supported_type!(logical_type) _add_parameter(logical_type) end
Adds a parameter to the aggregate function.
@param logical_type [DuckDB::LogicalType | :logical_type_symbol] the parameter type @return [DuckDB::AggregateFunction] self @raise [DuckDB::Error] if the type is not supported
Source
static VALUE rbduckdb_aggregate_function_set_name(VALUE self, VALUE name) {
rubyDuckDBAggregateFunction *p;
TypedData_Get_Struct(self, rubyDuckDBAggregateFunction, &aggregate_function_data_type, p);
const char *str = StringValuePtr(name);
duckdb_aggregate_function_set_name(p->aggregate_function, str);
return self;
}
Source
# File lib/duckdb/aggregate_function.rb, line 16 def return_type=(logical_type) logical_type = check_supported_type!(logical_type) _set_return_type(logical_type) end
Sets the return type for the aggregate function.
@param logical_type [DuckDB::LogicalType | :logical_type_symbol] the return type @return [DuckDB::AggregateFunction] self @raise [DuckDB::Error] if the type is not supported
Source
# File lib/duckdb/aggregate_function.rb, line 43 def set_special_handling _set_special_handling end
Sets special NULL handling for the aggregate function. By default DuckDB skips rows with NULL input values. Calling this method disables that behaviour so the update callback is invoked even when inputs are NULL, receiving nil for each NULL argument. This lets the function implement its own NULL semantics (e.g. counting NULLs).
Wraps duckdb_aggregate_function_set_special_handling.
@return [DuckDB::AggregateFunction] self