~/devreads

#array

5 posts

27 Mar 2025

lukaseder 1 min read

ARRAY types are a part of the ISO/IEC 9075 SQL standard. The standard specifies how to: But it is very unopinionated when it comes to function support. The ISO/IEC 9075-2:2023(E) 6.47 <array value expression> specifies concatenation of arrays, whereas the 6.48 <array value function> section lists a not extremely useful TRIM_ARRAY function, exclusively (using which … Continue reading When SQL…

sqlarrayarray typesclickhousedatabricks

10 Jun 2022

lukaseder 1 min read

I stumbled upon a very interesting question on Stack Overflow about how to use jOOQ’s MULTISET operator to nest a collection, and then filter the result by whether that nested collection contains a value. The question is jOOQ specific, but imagine, you have a query that nests collections using JSON in PostgreSQL. Assuming, as always, … Continue reading How to…

sqlarrayarray aggjooqmultiset

22 Feb 2022

lukaseder 1 min read

Questions that might be a bit more difficult to solve using ordinary SQL are questions of the kind: What films have the same actors as a given film X? As always, we’re using the sakila database for this example. What would be a possible way to solve this with SQL (for example, PostgreSQL, to be … Continue reading Use MULTISET…

jooq-in-usesqlarrayarray aggjooq

22 Jul 2020

lukaseder 1 min read

I just fixed a bug. The fix required me to initialise an Object[] array with the init values for each type, instead of just null, i.e. false for boolean, 0 for int, 0.0 for double, etc. So, instead of just doing: I needed: For the subjective 8E17th time, I wrote a loop. A loop that … Continue reading Could we…

javaaplarrayloopset

10 Feb 2017

lukaseder 1 min read

Sometimes, SQL can just be so beautiful. One of the less mainstream features in SQL is the array type (or nested collections). In fact, it’s so not mainstream that only 2 major databases actually support it: Oracle and PostgreSQL (and HSQLDB and H2 in the Java ecosystem). In PostgreSQL, you can write: Or in Oracle: … Continue reading Beautiful SQL:…

sqlarraylateralnested collectionsoracle