apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.26k stars 3.2k forks source link

[Bug] group_concat don't support using distinct with order by together #24581

Closed pengtao211 closed 2 months ago

pengtao211 commented 11 months ago

Search before asking

Version

2.0.1

What's Wrong?

1105 - errCode = 2, detailMessage = group_concat don't support using distinct with order by together: group_concat(DISTINCT time ORDER BY time ASC)

What You Expected?

I hope the group_concat support using distinct with order by together

How to Reproduce?

SELECT day, GROUP_CONCAT(distinct time ORDER BY time) FROM ( SELECT 'Monday' day, '15:00-21:00' time UNION ALL SELECT 'Monday' day, '09:00-13:00' time UNION ALL SELECT 'Monday' day, '09:00-13:00' time ) tab GROUP BY day

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

ixzc commented 11 months ago

This is not supported. You can do it another way

pengtao211 commented 11 months ago

This is not supported. You can do it another way

What is the other way?

ixzc commented 11 months ago

like this:

CREATE TABLE test_GROUP_CONCAT( value varchar(10) )ENGINE=OLAP DISTRIBUTED BY HASH(value)
PROPERTIES ( "replication_num" = "1" );

INSERT INTO test_GROUP_CONCAT (value) VALUES ('a'), ('b'), ('c'), ('c');

select GROUP_CONCAT( valueORDER BY value ASC) from ( select distinct value from test_GROUP_CONCAT ) a ;

over-space commented 2 months ago

group_concat can be converted to ARRAY_JOIN, ARRAY_SORT, COLLECT_SET/COLLECT_LIST combinations.

like this:

image
pengtao211 commented 2 months ago

group_concat can be converted to ARRAY_JOIN, ARRAY_SORT, COLLECT_SET/COLLECT_LIST combinations.

like this:

image

thank