#[aggregate]) in
better_duck_diesel::dsl::*. Use them in a grouped or aggregating .select.
Diesel core already ships
count/sum/avg/min/max (in diesel::dsl) — this crate adds only what
core lacks. Most aggregates return Nullable<…> because an empty group yields NULL; load into an
Option.General
Statistical
Double -> Nullable<Double> unless noted:
Dispersion & shape
Dispersion & shape
stddev_samp, stddev_pop, var_samp, var_pop, median, skewness, kurtosis, entropy,
mad, mode.Bivariate & regression
Bivariate & regression
corr(y, x), covar_samp(y, x), covar_pop(y, x), regr_slope(y, x), regr_intercept(y, x),
regr_r2(y, x), regr_count(y, x) (→Nullable<BigInt>).Approximate & quantiles
Bitwise
BigInt -> Nullable<BigInt>: bit_and(x), bit_or(x), bit_xor(x).
JSON
json_group_array(x: Text) (→Text) aggregates values into a JSON array; json_group_object(key, value)
(both Text, →Text) aggregates key/value pairs into a JSON object. See
JSON functions for the scalar side.
Custom aggregate UDFs
Your own aggregates registered with#[duckdb_aggregate] are callable the same way once declared with
define_sql_function! + #[aggregate]. See Calling your own UDFs and the
UDF macros.
See also
Select
Grouped selects and
GROUP BY.JSON functions
Scalar JSON helpers.
Calling your own UDFs
Register custom aggregates.
Type mapping
Reading
DuckList aggregate results.