duckdb-web icon indicating copy to clipboard operation
duckdb-web copied to clipboard

List comprehensions slightly under-documented

Open shoffmeister opened this issue 5 months ago • 0 comments

The documentation for list comprehensions at https://duckdb.org/docs/sql/functions/list#list-comprehension exists, essentially by way of saying "Python-style" and providing examples.

This is somewhat sparse, IMHO, and could use more words around the "if" part used for reducing the list.

Even more relevant might be explicitly mentioning that list comprehensions are "just" (very nice!) syntactic sugar on top of lambda functions (https://duckdb.org/docs/sql/functions/lambda.html): The combination of list_transform and list_reduce is an alternative representation of the list comprehension which helps whenever third-party tooling is not enabled to work with list comprehensions (yet) - see https://github.com/sqlfluff/sqlfluff/issues/6157

shoffmeister avatar Sep 08 '24 12:09 shoffmeister