UDA (User-Defined Analytic) object model for kdb Insights.¶
Classes:
- Uda – A callable User-Defined Analytic (UDA) registered in a kdb Insights deployment.
- UdaNamespace – Browsable, callable container for UDAs registered in a kdb Insights deployment.
- UdaParam – Read-only metadata for one parameter of a UDA.
Uda¶
Uda(name, endpoint, description, params, return_type, return_description, loaded_in, safe, agg_fn, tables, _conn)
A callable User-Defined Analytic (UDA) registered in a kdb Insights deployment.
You get Uda objects from Query.udas — never construct them directly.
Example
conn = Query(...)
# discover what's available
conn.udas # repr shows all UDAs grouped by namespace
dir(conn.udas.example) # tab-complete inside a namespace
# call a UDA — all parameters are keyword-only
result = conn.udas.example.myFunc(table="trade", column="price")
# target a specific assembly or tier, or route to QE
result = conn.udas.example.myFunc(
table="trade",
column="price",
scope={"assembly": "my-pkg"}, # optional
labels={"region": "amer"}, # optional
opts={"aggFn": "myCustomAggFn"}, # optional
use_qe=True, # optional, default False
)
# introspect
help(conn.udas.example.myFunc)
import inspect
inspect.signature(conn.udas.example.myFunc)
# reload after deployment changes
conn.refresh_udas()
Every UDA exposes three gateway parameters in addition to its own params:
scope— dict, target a specific assembly or tier. e.g.{"assembly": "my-pkg"}or{"assembly": "my-pkg", "tier": "hdb"}labels— dict, filter DAPs by label. e.g.{"region": "amer"}opts— dict, override request options. e.g.{"aggFn": "myAggFn"}use_qe— bool, route to the Query Environment instead of production (default:False)
Attributes:
- name – Full dotted name as registered in kdb, e.g.
example.myFunc. - _params – List of
UdaParamobjects describing each parameter. - _uda_loaded_in – Dict mapping assembly name to list of DAP instances.
- _uda_agg_fn – Name of the registered aggregation function, or empty string.
- _uda_tables – Sorted list of table names this UDA can query, derived from the assemblies it is loaded in.
UdaNamespace¶
UdaNamespace(conn)
Browsable, callable container for UDAs registered in a kdb Insights deployment.
Attach a Query and explore UDAs immediately — no manual fetch needed.
Example
conn = Query(...)
# top-level: shows all namespaces and any root-level UDAs
conn.udas
# q namespace `.example.daAPI` becomes a two-level attribute path
conn.udas.example.daAPI(table="trade", column="price", use_qe=True)
# check what's available
"example" in conn.udas # True if the 'example' namespace exists
dir(conn.udas.example) # tab-complete UDAs in that namespace
list(conn.udas) # top-level namespace/UDA names
# force a reload if the deployment has changed
conn.refresh_udas()
UDAs are loaded lazily from getMeta on the first access. Each q namespace
becomes a nested UdaNamespace; the leaf is a callable Uda object with a
full signature and docstring.
The root UdaNamespace lives at Query.udas. Child namespaces are the same
type — all the same methods apply at every level.
Functions:
- from_meta – Parse a getMeta response and return a populated UdaNamespace.
from_meta¶
from_meta(meta, conn)
Parse a getMeta response and return a populated UdaNamespace.
UdaParam¶
UdaParam(name, q_type, required, default, description)
Read-only metadata for one parameter of a UDA.
You won't normally construct these — they appear in Uda._params and
are rendered in Uda.__doc__ and repr(Uda).
Attributes:
- name (
str) – Parameter name as declared in the UDA. - q_type (
int | list | None) – Raw kdb type number (or list of numbers for union types). Usetype_labelfor the human-readable equivalent. - required (
bool) – Whether the parameter must be supplied on every call. - default (
Any) – Default value, orinspect.Parameter.emptyif none. - description (
str) – Free-text description from the UDA metadata.
type_label¶
type_label: str
Human-readable kdb type name, e.g. Symbol or Long.