Class: DuckDB::ScalarFunctionSet

Inherits:
Object
  • Object
show all
Defined in:
lib/duckdb/scalar_function_set.rb,
ext/duckdb/scalar_function_set.c

Overview

Note:

DuckDB::ScalarFunctionSet is experimental.

DuckDB::ScalarFunctionSet encapsulates DuckDB’s scalar function set, which allows registering multiple overloads of a scalar function under one name.

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ScalarFunctionSet

Returns a new instance of ScalarFunctionSet.

Parameters:

  • name (String, Symbol)

    the function set name shared by all overloads

Raises:

  • (TypeError)

    if name is not a String or Symbol



11
12
13
14
15
16
# File 'lib/duckdb/scalar_function_set.rb', line 11

def initialize(name)
  raise TypeError, "#{name.class} is not a String or Symbol" unless name.is_a?(String) || name.is_a?(Symbol)

  @name = name.to_s
  _initialize(@name)
end

Instance Method Details

#add(scalar_function) ⇒ self

Parameters:

Returns:

  • (self)

Raises:

  • (TypeError)

    if scalar_function is not a DuckDB::ScalarFunction

  • (DuckDB::Error)

    if the overload already exists in the set



22
23
24
25
26
27
28
29
# File 'lib/duckdb/scalar_function_set.rb', line 22

def add(scalar_function)
  unless scalar_function.is_a?(DuckDB::ScalarFunction)
    raise TypeError, "#{scalar_function.class} is not a DuckDB::ScalarFunction"
  end

  scalar_function.name = @name
  _add(scalar_function)
end