STRING_AGG missing functionality #14412
Open
+911
−170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
distinct
andorder by
clause forstring_agg
aggregate function #8260.Rationale for this change
See #14413 first.
Complete the missing functionality of the STRING_AGG function.
What changes are included in this PR?
Adds support for DISTINCT and ORDER_BY clauses by reusing the existing ARRAY_AGG functionality and building the whole STRING_AGG aggregation function on top of it. This way, the full STRING_AGG functionality is automatically implemented [almost] for free.
The rationale for reusing the ARRAY_AGG functionality is because both functions are very similar, with just two minor diferences:
In order to have the full STRING_AGG functionality, some small addition is also needed for the ARRAY_AGG function, as the current implementation is missing support for DISTINCT + ORDER BY. See #14413.
Are these changes tested?
Yes, both in unit tests and sqllogictests.
Are there any user-facing changes?
Users will be able to issue STRING_AGG calls with DISTINCT and ORDER BY clauses.