Skip to content

Proposal: Add list module to std for Array/List operations #5754

Description

@sunyeongchoi

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions