Skip to content

Commit

Permalink
[opt](regression test) Add string-like column order by test apache#26379
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiang-hhhh authored and seawinde committed Nov 12, 2023
1 parent f0af2af commit 4681fd0
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
60 changes: 60 additions & 0 deletions regression-test/data/query_p0/sort/sort.out
Original file line number Diff line number Diff line change
Expand Up @@ -3146,3 +3146,63 @@ z
3023-03-21T08:00 1023.1023 1023
3024-03-21T08:00 1024.1024 1024

-- !order_by_col_str --
1 A
2 A
5 B
6 B
3 a
4 a
7 b
8 b

-- !order_by_col_str_null --
2 \N
4 \N
6 \N
8 \N
1 A
5 B
3 a
7 b

-- !order_by_col_varchar --
1 A
2 A
5 B
6 B
3 a
4 a
7 b
8 b

-- !order_by_col_varchar_null --
2 \N
4 \N
6 \N
8 \N
1 A
5 B
3 a
7 b

-- !order_by_col_char --
1 A
2 A
5 B
6 B
3 a
4 a
7 b
8 b

-- !order_by_col_char_null --
2 \N
4 \N
6 \N
8 \N
1 A
5 B
3 a
7 b

54 changes: 54 additions & 0 deletions regression-test/suites/query_p0/sort/sort.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,58 @@ suite("sort") {
qt_order_by_float """ select /*SET_VAR(parallel_pipeline_task_num=1,parallel_fragment_exec_instance_num=1)*/ * from ${tblName} order by dc; """
qt_order_by_int """ select /*SET_VAR(parallel_pipeline_task_num=1,parallel_fragment_exec_instance_num=1)*/ * from ${tblName} order by ic; """
qt_order_by_uint """ select /*SET_VAR(parallel_pipeline_task_num=1,parallel_fragment_exec_instance_num=1)*/ * from ${tblName} order by time_period; """


// string order by test
// test purpose:
// 1. make sure order by string-like column will follow its ASCI value
// 2. make sure order by with null value works as expected
sql """ DROP TABLE IF EXISTS sort_string_orderby """
sql """ CREATE TABLE sort_string_orderby (
`row_id` INT NOT NULL,
`col_str` STRING NOT NULL,
`col_str_null` STRING NULL,
`col_varchar` VARCHAR(10) NOT NULL,
`col_varchar_null` VARCHAR(10) NULL,
`col_char` CHAR(10) NOT NULL,
`col_char_null` CHAR(10) NULL,
) ENGINE=OLAP
DUPLICATE KEY(`row_id`)
DISTRIBUTED BY HASH(`row_id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"disable_auto_compaction" = "true"
);
"""
sql """
INSERT INTO sort_string_orderby VALUES (1, 'A', 'A', 'A', 'A','A', 'A'),
(2, 'A', NULL, 'A', NULL, 'A', NULL),
(3, 'a', 'a', 'a', 'a','a', 'a'),
(4, 'a', NULL, 'a', NULL,'a', NULL),
(5, 'B', 'B', 'B', 'B','B', 'B'),
(6, 'B', NULL, 'B', NULL, 'B', NULL),
(7, 'b', 'b', 'b', 'b', 'b', 'b'),
(8, 'b', NULL, 'b', NULL,'b', NULL);
"""
qt_order_by_col_str """
select row_id, col_str from sort_string_orderby order by col_str,row_id
"""
qt_order_by_col_str_null """
select row_id, col_str_null from sort_string_orderby order by col_str_null,row_id;
"""
qt_order_by_col_varchar """
select row_id, col_varchar from sort_string_orderby order by col_varchar,row_id
"""
qt_order_by_col_varchar_null """
select row_id, col_varchar_null from sort_string_orderby order by col_varchar_null,row_id
"""
qt_order_by_col_char """
select row_id, col_char from sort_string_orderby order by col_char,row_id
"""
qt_order_by_col_char_null """
select row_id, col_char_null from sort_string_orderby order by col_char_null,row_id
"""
sql """
drop table if exists sort_string_orderby;
"""
}

0 comments on commit 4681fd0

Please sign in to comment.