SQL: Postgres-compatible generate_series function
Postgres has a generate_series function that's handy for use in testing. Users may appreciate having it for other reasons, so we may want to add it to SuperSQL.
$ psql postgres
psql (17.5 (Homebrew))
Type "help" for help.
postgres=# SELECT * FROM generate_series(0, 3);
generate_series
-----------------
0
1
2
3
(4 rows)
Details
At the time this issue is being opened, super is at commit bce1669.
I became aware of this function while running a sqllogictest that generates a bunch of data for itself to test cross joins. That specific sqllogictest happens to use a range function that's available in DuckDB but not Postgres. But while learning about range, I came across generate_series which is in Postgres, and it effectively looks like a more general approach that can cover all the functionality of range, e.g., here's that sqllogictest running in Postgres using generate_series.
$ psql postgres
psql (17.5 (Homebrew))
Type "help" for help.
postgres=# CREATE TABLE test (a INTEGER, b INTEGER);
CREATE TABLE
postgres=# INSERT INTO test VALUES (11, 1), (12, 2);
INSERT 0 2
postgres=# SELECT COUNT(*) FROM test t1, generate_series(0, 1999) t2;
count
-------
4000
(1 row)
In addition to being useful in running tests like this, users may also find functions like these handy for other reasons, e.g., they could be used to perform the equivalent of "for loops".