This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 7ca63665b4f [fix](agg) garbled characters in result of map_agg (#25318) 7ca63665b4f is described below commit 7ca63665b4f831e4c510c9056556feab70682e91 Author: Jerry Hu <mrh...@gmail.com> AuthorDate: Wed Oct 11 21:10:55 2023 -0500 [fix](agg) garbled characters in result of map_agg (#25318) --- .../aggregate_functions/aggregate_function_map.h | 5 +- .../data/query_p0/aggregate/map_agg.out | 5 ++ .../suites/query_p0/aggregate/map_agg.groovy | 60 ++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_map.h b/be/src/vec/aggregate_functions/aggregate_function_map.h index 38b69756e0a..f22a1e7b50b 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_map.h +++ b/be/src/vec/aggregate_functions/aggregate_function_map.h @@ -86,8 +86,9 @@ struct AggregateFunctionMapAggData { for (size_t i = 0; i != count; ++i) { StringRef key; if constexpr (std::is_same_v<K, String>) { - auto string = key_array[i].get<K>(); - key = string; + auto& string = key_array[i].get<K>(); + key.data = string.data(); + key.size = string.size(); } else { auto& k = key_array[i].get<KeyType>(); key.data = reinterpret_cast<const char*>(&k); diff --git a/regression-test/data/query_p0/aggregate/map_agg.out b/regression-test/data/query_p0/aggregate/map_agg.out index ebe4099c2d6..ef9e6371f1c 100644 --- a/regression-test/data/query_p0/aggregate/map_agg.out +++ b/regression-test/data/query_p0/aggregate/map_agg.out @@ -28,3 +28,8 @@ 2 2.4567 3.3300 4.5500 3 188.9980 998.9960 1024.1024 +-- !garbled_characters -- +001 90.0 92.0 80.0 \N +002 88.0 90.0 75.5 \N +003 70.0 85.0 90.0 82.0 + diff --git a/regression-test/suites/query_p0/aggregate/map_agg.groovy b/regression-test/suites/query_p0/aggregate/map_agg.groovy index ae165cc64a5..4fc90143464 100644 --- a/regression-test/suites/query_p0/aggregate/map_agg.groovy +++ b/regression-test/suites/query_p0/aggregate/map_agg.groovy @@ -161,6 +161,57 @@ suite("map_agg") { (3, "k3", 1024.1024) """ + sql "DROP TABLE IF EXISTS `test_map_agg_score`;" + sql """ + CREATE TABLE `test_map_agg_score`( + id INT(11) NOT NULL, + userid VARCHAR(20) NOT NULL COMMENT '用户id', + subject VARCHAR(20) COMMENT '科目', + score DOUBLE COMMENT '成绩' + ) + DUPLICATE KEY(`id`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "in_memory" = "false", + "storage_format" = "V2", + "light_schema_change" = "true", + "disable_auto_compaction" = "false" + ); + """ + + sql """ + INSERT INTO `test_map_agg_score` VALUES (1,'001','语文',90); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (2,'001','数学',92); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (3,'001','英语',80); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (4,'002','语文',88); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (5,'002','数学',90); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (6,'002','英语',75.5); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (7,'003','语文',70); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (8,'003','数学',85); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (9,'003','英语',90); + """ + sql """ + INSERT INTO `test_map_agg_score` VALUES (10,'003','政治',82); + """ + qt_sql1 """ WITH `labels` as ( SELECT `id`, map_agg(`label_name`, `value_field`) m FROM test_map_agg GROUP BY `id` @@ -217,8 +268,17 @@ suite("map_agg") { ORDER BY `id`; """ + qt_garbled_characters """ + select + userid, map['语文'] 语文, map['数学'] 数学, map['英语'] 英语, map['政治'] 政治 + from ( + select userid, map_agg(subject,score) as map from test_map_agg_score group by userid + ) a order by userid; + """ + sql "DROP TABLE IF EXISTS `test_map_agg`" sql "DROP TABLE IF EXISTS `test_map_agg_nullable`" sql "DROP TABLE IF EXISTS `test_map_agg_numeric_key`" sql "DROP TABLE IF EXISTS `test_map_agg_decimal`" + sql "DROP TABLE IF EXISTS `test_map_agg_score`" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org