Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/src/main/sphinx/functions/aggregate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,30 @@ Using a filter you retain all information::
General aggregate functions
---------------------------

.. function:: any_value(x) -> [same as input]

Returns an arbitrary non-null value ``x``, if one exists. ``x`` can be any
valid expression. This allows you to return values from columns that are not
directly part of the aggregation, inluding expressions using these columns,
in a query.

For example, the following query returns the customer name from the ``name``
column, and returns the sum of all total prices as customer spend. The
aggregation however uses the rows grouped by the customer identifier
``custkey`` a required, since only that column is guaranteed to be unique::

SELECT sum(o.totalprice) as spend,
any_value(c.name)
FROM tpch.tiny.orders o
JOIN tpch.tiny.customer c
ON o.custkey = c.custkey
GROUP BY c.custkey;
ORDER BY spend;

.. function:: arbitrary(x) -> [same as input]

Returns an arbitrary non-null value of ``x``, if one exists.
Returns an arbitrary non-null value of ``x``, if one exists. Identical to
:func:`any_value`.

.. function:: array_agg(x) -> array<[same as input]>

Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list-by-topic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Aggregate

For more details, see :doc:`aggregate`

* :func:`any_value`
* :func:`approx_distinct`
* :func:`approx_most_frequent`
* :func:`approx_percentile`
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/sphinx/functions/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ A
- :ref:`AND <logical-operators>`
- :ref:`ANY <quantified-comparison-predicates>`
- :func:`any_match`
- :func:`any_value`
- :func:`approx_distinct`
- :func:`approx_most_frequent`
- :func:`approx_percentile`
Expand Down