forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the bug which leading to wrong answer of sql string_agg(orderby) …
…& agg(distinct)
- Loading branch information
erchuan.ty
committed
Jan 25, 2024
1 parent
af90388
commit 2f303b5
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/regress/expected/aggregate_with_sort_distinct.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
drop schema if exists agg_sort_distinct_regress_schema cascade; | ||
NOTICE: schema "agg_sort_distinct_regress_schema" does not exist, skipping | ||
create schema if not exists agg_sort_distinct_regress_schema; | ||
set search_path to agg_sort_distinct_regress_schema; | ||
create table test_multi_order_agg(a int, b int); | ||
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table. | ||
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. | ||
insert into test_multi_order_agg values (1, 1), (1, null), (null, 1); | ||
set gp_enable_sort_distinct to on; | ||
select string_agg(a::text, ','), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
string_agg | string_agg | ||
------------+------------ | ||
1,1 | 1 | ||
(1 row) | ||
|
||
select string_agg(a::text, ',' order by b), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
string_agg | string_agg | ||
------------+------------ | ||
1,1 | 1 | ||
(1 row) | ||
|
||
set gp_enable_sort_distinct to off; | ||
select string_agg(a::text, ','), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
string_agg | string_agg | ||
------------+------------ | ||
1,1 | 1 | ||
(1 row) | ||
|
||
select string_agg(a::text, ',' order by b), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
string_agg | string_agg | ||
------------+------------ | ||
1,1 | 1 | ||
(1 row) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
drop schema if exists agg_sort_distinct_regress_schema cascade; | ||
create schema if not exists agg_sort_distinct_regress_schema; | ||
|
||
set search_path to agg_sort_distinct_regress_schema; | ||
|
||
create table test_multi_order_agg(a int, b int); | ||
|
||
insert into test_multi_order_agg values (1, 1), (1, null), (null, 1); | ||
|
||
set gp_enable_sort_distinct to on; | ||
select string_agg(a::text, ','), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
select string_agg(a::text, ',' order by b), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
|
||
set gp_enable_sort_distinct to off; | ||
select string_agg(a::text, ','), string_agg(distinct b::text, ',') from test_multi_order_agg; | ||
select string_agg(a::text, ',' order by b), string_agg(distinct b::text, ',') from test_multi_order_agg; |