Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gabotechs
Copy link
Contributor

@gabotechs gabotechs commented Feb 2, 2025

Which issue does this PR close?

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:

  • STRING_AGG works only with strings, while ARRAY_AGG works with any type.
  • The return of STRING_AGG is the same as ARRAY_AGG, but with the resulting array of strings joined by a delimiter.

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.

@github-actions github-actions bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) functions labels Feb 2, 2025
@gabotechs gabotechs force-pushed the string-agg-missing-functionality branch from 59ac6aa to fb56b81 Compare February 2, 2025 17:34
@github-actions github-actions bot removed the logical-expr Logical plan and expressions label Feb 2, 2025
@gabotechs gabotechs force-pushed the string-agg-missing-functionality branch from fb56b81 to 808e417 Compare February 2, 2025 17:37
@gabotechs gabotechs changed the title String agg missing functionality STRING_AGG missing functionality Feb 3, 2025
@alamb
Copy link
Contributor

alamb commented Feb 4, 2025

Close/reopen to rerun CI checks

@alamb alamb closed this Feb 4, 2025
@alamb alamb reopened this Feb 4, 2025
@alamb alamb closed this Feb 4, 2025
@alamb alamb reopened this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement distinct and order by clause for string_agg aggregate function
2 participants