This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new 562c68da81 [fix](agg_sort)fix bug of agg sort group concat with order
by (#18451)
562c68da81 is described below
commit 562c68da81d448abdd1f4a2d9fd52d102885a2d2
Author: TengJianPing <[email protected]>
AuthorDate: Fri Apr 7 14:18:01 2023 +0800
[fix](agg_sort)fix bug of agg sort group concat with order by (#18451)
---
be/src/vec/exprs/vectorized_agg_fn.cpp | 4 +--
.../query_p0/group_concat/test_group_concat.out | 23 +++++++++++++++++
.../query_p0/group_concat/test_group_concat.groovy | 30 ++++++++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exprs/vectorized_agg_fn.cpp
b/be/src/vec/exprs/vectorized_agg_fn.cpp
index 101717d4cd..213eb7bebd 100644
--- a/be/src/vec/exprs/vectorized_agg_fn.cpp
+++ b/be/src/vec/exprs/vectorized_agg_fn.cpp
@@ -74,8 +74,8 @@ Status AggFnEvaluator::create(ObjectPool* pool, const TExpr&
desc, const TSortIn
// to the order by functions
for (int i = 0; i < sort_size; ++i) {
agg_fn_evaluator->_sort_description.emplace_back(real_arguments_size +
i,
-
sort_info.is_asc_order[i] == true,
-
sort_info.nulls_first[i] == true);
+
sort_info.is_asc_order[i] ? 1 : -1,
+
sort_info.nulls_first[i] ? -1 : 1);
}
// Pass the real arguments to get functions
diff --git a/regression-test/data/query_p0/group_concat/test_group_concat.out
b/regression-test/data/query_p0/group_concat/test_group_concat.out
index e61bd4fd4f..0e6aab79a8 100644
--- a/regression-test/data/query_p0/group_concat/test_group_concat.out
+++ b/regression-test/data/query_p0/group_concat/test_group_concat.out
@@ -25,3 +25,26 @@ false
25699 1989
2147483647 255:1991:32767:32767
+-- !select_group_concat_order_by_all_data --
+1 1 1
+1 1 11
+1 2 2
+1 2 21
+1 3 3
+2 21 21
+2 21 211
+2 22 22
+2 22 222
+2 23 23
+
+-- !select_group_concat_order_by_desc1 --
+1 3, 2, 2, 1, 1
+2 23, 22, 22, 21, 21
+
+-- !select_group_concat_order_by_desc2 --
+1 3, 2, 21, 1, 11
+2 23, 22, 222, 21, 211
+
+-- !select_group_concat_order_by_desc3 --
+1 3, 21, 2, 11, 1
+2 23, 222, 22, 211, 21
diff --git
a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
index ad307c476a..a5781f39e1 100644
--- a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
+++ b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
@@ -32,4 +32,34 @@ suite("test_group_concat") {
SELECT abs(k3), group_concat(cast(abs(k2) as varchar), ":"
order by abs(k2), k1) FROM test_query_db.baseall group by abs(k3) order by
abs(k3)
"""
+
+ sql """ drop table if exists table_group_concat """
+ sql """create table table_group_concat ( b1 varchar(10) not null, b2 int
not null, b3 varchar(10) not null )
+ ENGINE=OLAP
+ DISTRIBUTED BY HASH(b3) BUCKETS 4
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+
+ sql """insert into table_group_concat values('1', 1, '1'),('1', 2,
'2'),('1', 3, '3');"""
+ sql """insert into table_group_concat values('1', 1, '11'),('1', 2,
'21');"""
+ sql """insert into table_group_concat values('2', 21, '21'),('2', 22,
'22'),('2', 23, '23');"""
+ sql """insert into table_group_concat values('2', 21, '211'),('2', 22,
'222');"""
+
+ qt_select_group_concat_order_by_all_data """
+ select * from table_group_concat order by b1, b2, b3;
+ """
+ qt_select_group_concat_order_by_desc1 """
+ SELECT b1, group_concat(cast(abs(b2) as varchar) order by
abs(b2) desc) FROM table_group_concat group by b1 order by b1
+ """
+
+ qt_select_group_concat_order_by_desc2 """
+ SELECT b1, group_concat(cast(abs(b3) as varchar) order by
abs(b2) desc, b3) FROM table_group_concat group by b1 order by b1
+ """
+ qt_select_group_concat_order_by_desc3 """
+ SELECT b1, group_concat(cast(abs(b3) as varchar) order by
abs(b2) desc, b3 desc) FROM table_group_concat group by b1 order by b1
+ """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]