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

feature: LIST_AGG #16472

Open
BohuTANG opened this issue Sep 19, 2024 · 3 comments
Open

feature: LIST_AGG #16472

BohuTANG opened this issue Sep 19, 2024 · 3 comments
Assignees
Labels
C-feature Category: feature good first issue Category: good first issue

Comments

@BohuTANG
Copy link
Member

BohuTANG commented Sep 19, 2024

Summary

Syntax

Aggregate function

LIST_AGG( [ DISTINCT ] <expr1> [, <delimiter> ] )
    [ WITHIN GROUP ( <orderby_clause> ) ]

Window function

LIST_AGG( [ DISTINCT ] <expr1> [, <delimiter> ] )
    [ WITHIN GROUP ( <orderby_clause> ) ]
    OVER ( [ PARTITION BY <expr2> ] )

Example

CREATE TABLE orders (
    o_orderstatus VARCHAR,
    o_clerk VARCHAR,
    o_totalprice DECIMAL(10, 2)
);

INSERT INTO orders (o_orderstatus, o_clerk, o_totalprice) VALUES
('F', 'Clerk#0001', 550000.00),
('O', 'Clerk#0002', 600000.00),
('F', 'Clerk#0003', 530000.00),
('O', 'Clerk#0004', 540000.00),
('P', 'Clerk#0005', 560000.00),
('F', 'Clerk#0006', 450000.00), 
('P', 'Clerk#0007', 700000.00),
('O', 'Clerk#0008', 800000.00),
('F', 'Clerk#0009', 520000.01);

SELECT
    o_orderstatus,
    LIST_AGG(o_clerk, ', ') WITHIN GROUP (ORDER BY o_totalprice DESC) AS clerks_list
FROM
    orders
WHERE
    o_totalprice > 520000
GROUP BY
    o_orderstatus;


@BohuTANG BohuTANG added C-feature Category: feature good first issue Category: good first issue labels Sep 19, 2024
@b41sh
Copy link
Member

b41sh commented Sep 23, 2024

The string_agg function we have implemented is the same as the list_agg, we just need to support the WITHIN GROUP and window function, and the list_agg can be used as an alias for the string_agg.

@arkzuse
Copy link
Contributor

arkzuse commented Sep 29, 2024

i would like to take this issue

@arkzuse
Copy link
Contributor

arkzuse commented Oct 1, 2024

hi I have a doubt.
is WITHIN GROUP clause implemented? I couldn't find it. If not where I should implement it?

for WITHIN GROUP changes have to be made in accumulate right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature good first issue Category: good first issue
Projects
None yet
Development

No branches or pull requests

3 participants