arraymath
Array math and operators that work element by element on the contents of arrays
pg_arraymath : Array math and operators that work element by element on the contents of arrays
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4770 | arraymath | pg_arraymath | 1.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 | intarray floatvec aggs_for_vecs aggs_for_arrays collection hstore pgbson |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1 |
18 17 16 15 14 | pg_arraymath |
- |
| RPM | PIGSTY | 1.1 |
18 17 16 15 14 | pg_arraymath_$v |
- |
| DEB | PIGSTY | 1.1 |
18 17 16 15 14 | postgresql-$v-pg-arraymath |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el8.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el9.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el9.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el10.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| el10.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d12.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d12.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d13.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| d13.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u22.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u22.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u24.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u24.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u26.x86_64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
| u26.aarch64 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 | PIGSTY 1.1 |
Source
github.com/pramsey/pgsql-arraymath
pgsql-arraymath-1.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
arraymath: element-by-element array operations for PostgreSQL
Provides element-by-element operators and utility functions for integer, float, and numeric arrays.
Operators
All operators are prefixed with @ to indicate element-by-element behavior. Works with array-vs-array (same length or cycling) and array-vs-scalar.
| Operator | Description | Returns |
|---|---|---|
@= |
Element-by-element equality | boolean[] |
@< |
Element-by-element less than | boolean[] |
@> |
Element-by-element greater than | boolean[] |
@<= |
Element-by-element less than or equals | boolean[] |
@>= |
Element-by-element greater than or equals | boolean[] |
@+ |
Element-by-element addition | same type |
@- |
Element-by-element subtraction | same type |
@* |
Element-by-element multiplication | same type |
@/ |
Element-by-element division | same type |
Functions
| Function | Description |
|---|---|
array_sum(anyarray) |
Sum of all elements |
array_avg(anyarray) |
Average of all elements |
array_min(anyarray) |
Minimum element |
array_max(anyarray) |
Maximum element |
array_median(anyarray) |
Median element |
array_sort(anyarray) |
Sort ascending |
array_rsort(anyarray) |
Sort descending |