aggs_for_vecs
aggs_for_vecs
aggs_for_vecs : Aggregate functions for array inputs
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4740 | aggs_for_vecs
|
aggs_for_vecs
|
1.4.1 |
FUNC
|
MIT
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | aggs_for_arrays
first_last_agg
arraymath
floatvec
vector
topn
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.4.1 |
18
17
16
15
14
|
aggs_for_vecs |
- |
| RPM | PIGSTY
|
1.4.1 |
18
17
16
15
14
|
aggs_for_vecs_$v |
- |
| DEB | PIGSTY
|
1.4.1 |
18
17
16
15
14
|
postgresql-$v-aggs-for-vecs |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
el8.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
el9.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
el9.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
el10.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
el10.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
d12.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
d12.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
d13.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
d13.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
u22.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
u22.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
u24.x86_64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
u24.aarch64
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
PIGSTY 1.4.1
|
Source
pig build pkg aggs_for_vecs; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install aggs_for_vecs; # install via package name, for the active PG version
pig install aggs_for_vecs -v 18; # install for PG 18
pig install aggs_for_vecs -v 17; # install for PG 17
pig install aggs_for_vecs -v 16; # install for PG 16
pig install aggs_for_vecs -v 15; # install for PG 15
pig install aggs_for_vecs -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION aggs_for_vecs;Usage
aggs_for_vecs: aggregate functions for arrays (vector/row-based)
Provides aggregate functions that operate on arrays as vectors, computing position-wise statistics across multiple rows. Supports SMALLINT, INTEGER, BIGINT, REAL, and DOUBLE PRECISION.
CREATE EXTENSION aggs_for_vecs;Aggregate Functions
| Function | Description |
|---|---|
vec_to_count(anyarray) |
Count of non-nulls in each position |
vec_to_sum(anyarray) |
Sum in each position |
vec_to_min(anyarray) |
Minimum in each position |
vec_to_max(anyarray) |
Maximum in each position |
vec_to_mean(anyarray) |
Average in each position (returns FLOAT[]) |
vec_to_weighted_mean(values, weights) |
Weighted average in each position |
vec_to_var_samp(anyarray) |
Sample variance in each position |
vec_to_first(anyarray) |
First non-null in each position (use with ORDER BY) |
vec_to_last(anyarray) |
Last non-null in each position (use with ORDER BY) |
hist_2d(x, y, ...) |
2-D histogram |
hist_md(vals, indexes, ...) |
N-dimensional histogram |
Non-Aggregate Functions
| Function | Description |
|---|---|
vec_add(l, r) |
Element-wise addition |
vec_sub(l, r) |
Element-wise subtraction |
vec_mul(l, r) |
Element-wise multiplication |
vec_div(l, r) |
Element-wise division |
vec_elements(array, indexes) |
Select elements at given indexes |
pad_vec(array, length) |
Extend array to given length with NULLs |
vec_coalesce(array, default) |
Replace NULLs with default |
vec_trim_scale(numeric[]) |
Trim trailing zeros from NUMERIC elements |
vec_without_outliers(vals, mins, maxs) |
Replace outliers with NULL |
Examples
-- Position-wise minimum across rows
SELECT vec_to_min(vals) FROM (VALUES
(ARRAY[1,2,3,4]),
(ARRAY[5,0,-5,0]),
(ARRAY[3,6,0,9])
) AS t(vals);
-- {1,0,-5,0}
-- Position-wise average
SELECT vec_to_mean(vals) FROM my_table;Last updated on