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.
The grammar admits an in-call
ORDER BYclause onARRAY_AGG(), but semantic analysis currently rejects it:Such an in-call
ORDER BYclause is a desirable feature forARRAY_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.