Skip to main content
Vane Data / Reference

UDF reference

Vane UDFs run Python code on data in a Relation. Use this reference to choose an API and check its signature, parameters, return value, errors, and examples.

Choose an API

"Output and cardinality" describes the row-count relationship for a call. 1 → 1 returns one row per input row, while 1 → 0..N may return zero or more. N → N preserves a batch's row count, while N → M may change it.

APIPython receivesOutput and cardinalityUse it when
vane.funcScalar argumentsOne projected value, 1 → 1A synchronous function computes one value per row
vane.clsScalar argumentsOne projected value, 1 → 1The scalar callable needs a reusable instance
vane.func.batchArrow columnsOne equal-length logical result; Struct fields can expand into columns, N → NA function operates on Arrow columns
vane.cls.batchArrow columnsOne equal-length logical result; Struct fields can expand into columns, N → NBatched work needs a reusable instance
Relation.mapOne scalar per current columnKeeps input and appends value, 1 → 1Every input row produces one additional value
Relation.flat_mapOne row dictComplete declared schema, 1 → 0..NOne row may produce zero, one, or many rows
Relation.map_batchesOne pyarrow.TableComplete declared schema, N → MA table batch may change shape or row count

See the Expression UDF overview for Expression-specific call and placement rules.

Register an Expression UDF for SQL

APIPurpose
vane.attach_functionRegister a decorated or raw Python callable as a SQL function on a connection
vane.detach_functionRemove a registered SQL function from a connection

Registration provides a SQL name for an Expression UDF. It does not change the projection-only placement rule.

Execution guarantees

Task and Actor backends may retry a call after a failure. Vane does not provide exactly-once UDF execution, so code with external effects must be idempotent.

Callable classes run in independent, ephemeral Actor instances. Work has no Actor affinity or global ordering, and Actor reconstruction resets local state. Use instance state only for reconstructible resources such as models, clients, and caches, not as shared or durable query state.