UDFCollection¶
This UDFCollection object is loaded from udfs.yaml at the package root.
It contains the package's UDF and UDA definitions, which are read and written by the CLI as part of the package model.
In practice, these definitions are created from source files in the package.
The CLI scans q and Python code for the UDF metadata annotations and then
materializes the discovered definitions into udfs.yaml.
Examples:
// @udf.name("custom_map")
// @udf.description(
// "Custom map function providing filtering against incoming data "
// "for a specified column and maximum threshold."
// )
// @udf.tag("sp")
// @udf.category("map")
.test.my_custom_udf:{[table;params]
select from table where params[`column]>params`threshold
}
import numpy as np
from kxi.packages.decorators import udf
@udf.name("custom_py_map")
@udf.description("Custom Python UDF making use of numpy")
@udf.tag("sp")
@udf.category("map")
def py_udf(table, params):
# Multiply the target column by random values between 0 and 1.
n = len(table)
table[params["column"]] = table[params["column"]] * np.random.random(n)
return table
| Key | Value |
|---|---|
type |
object |
relationship |
Package -> UDFCollection |
object path |
$.udfs |
package file path |
{package-root}/udfs.yaml |
Fields¶
| Field | Type | Required | Description | Constraints | Default |
|---|---|---|---|---|---|
metadata |
ComponentMetadata | null |
no | - | - | null |
udfs |
array<UDF | UDA> |
no | - | - | - |
uuid |
string | null |
no | - | format: "uuid" |
- |
Links To¶
metadata:ComponentMetadataudfs:UDAudfs:UDF
Used In¶
Packageviaudfs