8000 distinct aggregate should distinct on all arguments instead of only the first · Issue #10942 · risingwavelabs/risingwave · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

distinct aggregate should distinct on all arguments instead of only the first #10942

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

Open
stdrc opened this issue Jul 14, 2023 · 4 comments
Open
Assignees
Labels
A-agg Area: Aggregate. type/enhancement Type: Enhancement for an existing feature.

Comments

@stdrc
Copy link
Member
stdrc commented Jul 14, 2023

Previously string_agg misbehave due to this issue if DistinctAggRule is not applied (#10826). After the fix #10864, string_agg now only allow constant delim when specifying DISTINCT option, while the issue still remains. Currently it doesn't cause any substantial harm, but may need to be fixed if users require multiple non-const distinct arguments when using later UDAF feature, so leave this issue just as a reminder.

cc @wangrunji0408

@stdrc stdrc added the type/feature Type: New feature. label Jul 14, 2023
@github-actions github-actions bot added this to the release-0.19 milestone Jul 14, 2023
@stdrc stdrc removed this from the release-0.19 milestone Jul 14, 2023
@fuyufjh fuyufjh added this to the release-1.1 milestone Jul 18, 2023
@xiangjinwu xiangjinwu modified the milestones: release-1.1, release-1.2 Aug 8, 2023
@st1page st1page modified the milestones: release-1.2, release-1.3 Sep 11, 2023
@stdrc stdrc modified the milestones: release-1.3, future-release-1.5 Oct 10, 2023
@fuyufjh fuyufjh modified the milestones: release-1.5, release-1.6 Dec 6, 2023
@wangrunji0408 wangrunji0408 modified the milestones: release-1.6, release-1.7 Jan 9, 2024
@wangrunji0408 wangrunji0408 modified the milestones: release-1.7, release-1.8 Mar 6, 2024
Copy link
Contributor
github-actions bot commented Jul 3, 2024

This issue has been open for 60 days with no activity.

If you think it is still relevant today, and needs to be done in the near future, you can comment to update the status, or just manually remove the no-issue-activity label.

You can also confidently close this issue as not planned to keep our backlog clean.
Don't worry if you think the issue is still valuable to continue in the future.
It's searchable and can be reopened when it's time. 😄

@st1page
Copy link
Contributor
st1page commented Oct 29, 2024

IIUC, PG does not support that

postgres=# explain select count(distinct a,b) from t;
ERROR:  function count(integer, integer) does not exist
LINE 1: explain select count(distinct a,b) from t;
                       ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

But it support count(distinct (a,b)) or count(distinct ROW(a,b))

postgres=# explain select count(distinct (a,b)) from t;
                           QUERY PLAN
-----------------------------------------------------------------
 Aggregate  (cost=169.81..169.82 rows=1 width=8)
   ->  Sort  (cost=158.51..164.16 rows=2260 width=8)
         Sort Key: (ROW(a, b))
         ->  Seq Scan on t  (cost=0.00..32.60 rows=2260 width=8)
(4 rows)

@stdrc
Copy link
Member Author
stdrc commented Nov 1, 2024

IIUC, PG does not support that

postgres=# explain select count(distinct a,b) from t;
ERROR:  function count(integer, integer) does not exist
LINE 1: explain select count(distinct a,b) from t;
                       ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

I mean the functions that accept more than 1 arguments, e.g. string_agg. Example in PG:

create table t (a int, b int);
insert into t values (1, 1), (2, 2), (2, 3), (2, 2), (3, 3), (4, 4);

select string_agg(distinct a::text || ']', '[' || b::text) from t;

PG allows distinct in function call accepting multiple arguments, and the semantics is to distinct on all of the arguments. Currently we don't support this. For string_agg, this is not a big problem actually, however I think this may be useful when using UDAF.

@st1page
Copy link
Contributor
st1page commented Nov 4, 2024

PG allows distinct in function call accepting multiple arguments, and the semantics is to distinct on all of the arguments

appalled to know that

@stdrc stdrc self-assigned this Dec 10, 2024
@stdrc stdrc added A-agg Area: Aggregate. type/enhancement Type: Enhancement for an existing feature. and removed type/feature Type: New feature. labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-agg Area: Aggregate. type/enhancement Type: Enhancement for an existing feature.
Projects
None yet
Development

No branches or pull requests

5 participants
0