[BugFix](sort) use correct agg function when using 2 phase sort for agg table (#16185)

This commit is contained in:
AlexYue
2023-02-01 20:07:43 +08:00
committed by GitHub
parent 0842aa2947
commit bb0d4ba787
4 changed files with 24 additions and 0 deletions

View File

@ -77,6 +77,8 @@ public:
int frac() const { return _frac; }
inline bool visible() const { return _visible; }
void set_aggregation_method(FieldAggregationMethod agg) { _aggregation = agg; }
/**
* Add a sub column.
*/

View File

@ -102,6 +102,8 @@ Status NewOlapScanner::prepare(const TPaloScanRange& scan_range,
rowid_column.set_has_default_value(true);
// fake unique id
rowid_column.set_unique_id(INT32_MAX);
rowid_column.set_aggregation_method(
FieldAggregationMethod::OLAP_FIELD_AGGREGATION_REPLACE);
rowid_column.set_type(FieldType::OLAP_FIELD_TYPE_STRING);
_tablet_schema->append_column(rowid_column);
}

View File

@ -10,3 +10,5 @@
-- !sort_string_on_fe --
true
-- !sql --

View File

@ -23,4 +23,22 @@ suite("sort") {
qt_sort_string_single_column """ select * from ( select '汇总' as a union all select '2022-01-01' as a ) a order by 1 """
qt_sort_string_multiple_columns """ select * from ( select '汇总' as a,1 as b union all select '2022-01-01' as a,1 as b ) a order by 1,2 """
qt_sort_string_on_fe """ select '汇总' > '2022-01-01' """
sql """CREATE TABLE IF NOT EXISTS Test2PhaseSortWhenAggTable
(`l1` VARCHAR(20) NOT NULL, `l2` VARCHAR(20) NOT NULL, `id` INT REPLACE NOT NULL, `maximum` INT MAX DEFAULT "0" )
ENGINE=olap AGGREGATE KEY(`l1`, `l2`) PARTITION BY LIST(`l1`, `l2`) ( PARTITION `p1` VALUES IN (("a", "a"), ("b", "b"), ("c", "c")),
PARTITION `p2` VALUES IN (("d", "d"), ("e", "e"), ("f", "f")), PARTITION `p3` VALUES IN (("g", "g"), ("h", "h"), ("i", "i")) ) DISTRIBUTED BY HASH(`l1`) BUCKETS 2 PROPERTIES ( "replication_num" = "1" )"""
sql """insert into Test2PhaseSortWhenAggTable values ("a", "a", 1, 1), ("b", "b", 3, 2), ("c", "c", 3, 3), ("d", "d", 4, 4), ("e", "e", 5, 5), ("f", "f", 6, 6), ("g", "g", 7, 7), ("h", "h", 8, 8), ("i", "i", 9, 9)"""
qt_sql """
SELECT /*+ SET_VAR(query_timeout = 600) */ ref_0.`l1` AS c0,
bitmap_empty() AS c1,
ref_0.`l1` AS c2
FROM Test2PhaseSortWhenAggTable AS ref_0
WHERE ref_0.`l2` IS NOT NULL
ORDER BY ref_0.`l1` DESC
LIMIT 110
OFFSET 130
"""
}