As modern OLAP engines (such as DuckDB, ClickHouse, BigQuery, and PostgreSQL) increasingly support complex data types like Arrays and Lists, there is a growing need for a standardized way to handle these types in PRQL.
Currently, PRQL has a dedicated text module for string manipulations. I propose introducing a list (or array) module to provide a consistent and intuitive API for common list operations, such as checking for the existence of elements.
I suggest adding a list module to the standard library with the following functions. These functions will allow users to perform membership tests on arrays easily.
| function |
parameters |
description |
| has |
value arr |
Returns true if arr contains value |
| has_any |
values arr |
Returns true if arr contains any value from values |
| has_all |
values arr |
Returns true if arr contains all values from values |
from employees
derive {
has_title = ([title, "CEO"] | list.has title),
has_any_role = ([title, country] | list.has_any [country, "CEO"]),
}
I am happy to work on the implementation and the necessary compiler mappings for various dialects if the community agrees with this direction. What do you think?
As modern OLAP engines (such as DuckDB, ClickHouse, BigQuery, and PostgreSQL) increasingly support complex data types like Arrays and Lists, there is a growing need for a standardized way to handle these types in PRQL.
Currently, PRQL has a dedicated text module for string manipulations. I propose introducing a
list(orarray) module to provide a consistent and intuitive API for common list operations, such as checking for the existence of elements.I suggest adding a
listmodule to the standard library with the following functions. These functions will allow users to perform membership tests on arrays easily.valuearrarrcontainsvaluevaluesarrarrcontains any value fromvaluesvaluesarrarrcontains all values fromvaluesI am happy to work on the implementation and the necessary compiler mappings for various dialects if the community agrees with this direction. What do you think?