-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STRING_AGG missing functionality #14412
base: main
Are you sure you want to change the base?
Conversation
59ac6aa
to
fb56b81
Compare
fb56b81
to
808e417
Compare
Close/reopen to rerun CI checks |
808e417
to
4abf8a0
Compare
@@ -5568,6 +5573,16 @@ SELECT STRING_AGG(x,',') FROM strings WHERE g > 100 | |||
---- | |||
NULL | |||
|
|||
query T | |||
SELECT STRING_AGG(DISTINCT x,',') FROM strings WHERE g > 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing space between the x
and ','
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️ It's the format that all the previous STRING_AGG tests were following, I kept it for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistency always wins over correctness!
4abf8a0
to
b36a9c5
Compare
b36a9c5
to
c022671
Compare
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.