Aggregate UDFs (experimental)

Aggregate user-defined function APIs

agg

agg()

Aggregate user-defined functions.

The agg class itself is not a public API, its methods are.

Methods

Name Description
builtin Construct an aggregate user-defined function that is built-in to the backend.

builtin

builtin(fn=None, *, name=None, database=None, catalog=None, signature=None, **kwargs)

Construct an aggregate user-defined function that is built-in to the backend.

Parameters

Name Type Description Default
fn The function to wrap. None
name The name of the UDF in the backend if different from the function name. None
database The database in which the builtin function resides. None
catalog The catalog in which the builtin function resides. None
signature If present, a tuple of the form ((arg0type, arg1type, ...), returntype). For example, a function taking an int and a float and returning a string would be ((int, float), str). If not present, the signature will be derived from the type annotations of the wrapped function. None
kwargs Additional backend-specific configuration arguments for the UDF. {}

Examples

>>> import ibis
>>> ibis.options.interactive = True
>>> @ibis.udf.agg.builtin
... def favg(a: float) -> float:
...     '''Compute the average of a column using Kahan summation.'''
>>> t = ibis.examples.penguins.fetch()
>>> favg(t.bill_length_mm)

┌──────────┐
│ 43.92193 │
└──────────┘
Back to top