Skip to main content

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

teal-frame/scalar-function

Interfaces​

InterfaceDescription
ScalarFunctionSpec-

Type Aliases​

ScalarFunctionImpl​

ScalarFunctionImpl = (value, index) => unknown

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

A per-value implementation, matching what FieldTransformConfig.create / FieldValidateConfig.create return: (value, index) => result.

Parameters​

ParameterType
valueunknown
indexnumber

Returns​

unknown

Variables​

ARGUMENT_SETS_KEPT​

const ARGUMENT_SETS_KEPT: 256 = 256

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

How many argument sets' implementations one UDF keeps; the least recently used is dropped.

Functions​

createScalarFunction()​

createScalarFunction(spec): DuckDBScalarFunction

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

Wraps a per-row JS function as a vectorized DuckDB scalar function.

The binding is chunk-based (mainFunction(info, chunk, outputVector)), so the JS boundary is crossed once per chunk of about 2048 rows, not once per row.

Parameters​

ParameterType
specScalarFunctionSpec

Returns​

DuckDBScalarFunction


makeResultCoercion()​

makeResultCoercion(fieldConfig, childConfig?): (value) => unknown

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

Coerces a function result into its declared type as a DataFrame Builder does (every Builder's _valueFrom is coerceToType(config)). A result that does not match is converted or throws the same way: setDefault or toJSON on an Integer column gives "5", and ceil(1e21) into an Integer throws.

The bigint normalizer runs first, as on ingest: toBigIntOrThrow adds 1 to a value it parses past 2^53 but returns a bigint unchanged, and the value converter later subtracts 1. Passing a large bigint as a decimal string keeps it exact. See makeBigIntInputNormalizer.

Parameters​

ParameterType
fieldConfigDataTypeFieldConfig
childConfig?DataTypeFields

Returns​

(value) => unknown