cockroachdb / cockroachdb/cockroach

sql: min/max and window functions should support array types

Open
#113,651 2 comments 0 reactions 0 assignees View on GitHub
C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Postgres allows calling `min` and `max` with an array data type:
```
postgres=# create table t2 (x int[]);
CREATE TABLE
postgres=# insert into t2 values ('{1, 2}'), ('{3}');
INSERT 0 2
postgres=# select min(x) from t2;
min
-------
{1,2}
(1 row)

postgres=# select max(x) from t2;
max
-----
{3}
(1 row)
```
but CRDB currently doesn't:
```
root@localhost:26257/system/defaultdb> create table t2 (x int[]);
CREATE TABLE

Time: 18ms total (execution 17ms / network 0ms)

root@localhost:26257/system/defaultdb> insert into t2 values ('{1, 2}'), ('{3}');
INSERT 0 2

Time: 23ms total (execution 22ms / network 0ms)

root@localhost:26257/system/defaultdb> select min(x) from t2;
ERROR: unknown signature: min(int[])
SQLSTATE: 42883
root@localhost:26257/system/defaultdb> select max(x) from t2;
ERROR: unknown signature: max(int[])
SQLSTATE: 42883
```

Jira issue: CRDB-33090

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.