Skip to content

Support the in-call ORDER BY clause for ARRAY_AGG() #4498

Description

@robert-brunel

The grammar admits an in-call ORDER BY clause on ARRAY_AGG(), but semantic analysis currently rejects it:

SELECT ARRAY_AGG(val ORDER BY val) FROM T1
-- UNSUPPORTED_QUERY: an ORDER BY clause is not supported for ARRAY_AGG()

Such an in-call ORDER BY clause is a desirable feature for ARRAY_AGG(), because the order of the elements within the resulting array is otherwise unspecified. They are collected in whatever order the rows happen to be read in, which depends on the plan chosen for the query and in particular on which index is used.

Note: The grammar admits the same clause for GROUP_CONCAT(), which would need the same treatment. However, that function is not implemented yet.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions