Skip to main content

@terascope/data-mate / teal-frame/scalar-function / ScalarFunctionSpec

Interface: ScalarFunctionSpec

Defined in: data-mate/src/teal-frame/scalar-function.ts:14

Properties​

PropertyTypeDescriptionDefined in
callWithNull?booleanCall fn for rows where the argument is null. Defaults to false, which matches DataFrame: transformVectorToBuilder iterates vector.values(), which skips nil entries, so a transform never receives a null. DuckDB passes nulls to a UDF, so the skip is done here.data-mate/src/teal-frame/scalar-function.ts:61
fn?ScalarFunctionImplThe implementation, called once per row. This should come from a function config's create() via tealFrameAdapter, not be written by hand. The function configs already define the name, arguments, accepted types, output_type, and null and array handling, so restating them here would duplicate them. Exactly one of fn and fnForArgs is set.data-mate/src/teal-frame/scalar-function.ts:43
fnForArgs?(argsText) => ScalarFunctionImplBuilds the implementation for one argument set from its JSON text, which the SQL passes as a second, constant parameter: dm_lookup_x(code, '{"in":{...}}'). This keeps the number of registered UDFs bounded. DuckDB cannot unregister a scalar function, so registering one UDF per argument set (per lookup table, regex or format) would grow without limit in a long-running process. Passing the arguments as a parameter means one UDF per function and type signature, and each argument set's implementation is cached in a bounded LRU (ARGUMENT_SETS_KEPT).data-mate/src/teal-frame/scalar-function.ts:54
namestringThe name it is called by in SQL.data-mate/src/teal-frame/scalar-function.ts:16
parameterDataTypeFieldConfig | FieldTypeThe single value argument: a bare field type, or a full field config for a list, struct or JSON value, which a bare type cannot express. See udfTypeFor.data-mate/src/teal-frame/scalar-function.ts:21
parameterChildren?DataTypeFields | ReadonlyDataTypeFieldsChildren of the parameter, for an Object/Tuple parameter.data-mate/src/teal-frame/scalar-function.ts:23
returnsDataTypeFieldConfigThe result's field config, not just its type. The returned JS value must be converted to DuckDB's representation (a BIGINT vector rejects a number, for example). makeValueConverter, which fromRecords also uses, does that from the config.data-mate/src/teal-frame/scalar-function.ts:31
returnsChildren?DataTypeFields | ReadonlyDataTypeFieldsChildren of the result type, for Object/Tuple results.data-mate/src/teal-frame/scalar-function.ts:33