Skip to content

Commit 7626ed5

Browse files
authored
fix(cubestore): Aggregate function MERGE not allowed for column type bytes (#5166)
1 parent ae78a8d commit 7626ed5

File tree

2 files changed

+61
-0
lines changed
  • rust/cubestore

2 files changed

+61
-0
lines changed

rust/cubestore/cubestore-sql-tests/src/tests.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ pub fn sql_tests() -> Vec<(&'static str, TestFn)> {
199199
planning_filter_index_selection,
200200
),
201201
t("planning_aggregate_index", planning_aggregate_index),
202+
202203
t("aggregate_index", aggregate_index),
203204
t("aggregate_index_hll", aggregate_index_hll),
205+
t("aggregate_index_with_hll_bytes", aggregate_index_with_hll_bytes),
204206
t("aggregate_index_errors", aggregate_index_errors),
205207
t("inline_tables", inline_tables),
206208
t("inline_tables_2x", inline_tables_2x),
@@ -5497,6 +5499,64 @@ async fn aggregate_index(service: Box<dyn SqlClient>) {
54975499
);
54985500
}
54995501

5502+
async fn aggregate_index_with_hll_bytes(service: Box<dyn SqlClient>) {
5503+
service.exec_query("CREATE SCHEMA s").await.unwrap();
5504+
service
5505+
.exec_query(
5506+
"CREATE TABLE s.Orders(a int, b int, hll bytes)
5507+
AGGREGATIONS(merge(hll))
5508+
AGGREGATE INDEX agg_index (a, b)
5509+
",
5510+
)
5511+
.await
5512+
.unwrap();
5513+
let sparse = "X'020C0200C02FF58941D5F0C6'";
5514+
let dense = "X'030C004020000001000000000000000000000000000000000000050020000001030100000410000000004102100000000000000051000020000020003220000003102000000000001200042000000001000200000002000000100000030040000000010040003010000000000100002000000000000000000031000020000000000000000000100000200302000000000000000000001002000000000002204000000001000001000200400000000000001000020031100000000080000000002003000000100000000100110000000000000000000010000000000000000000000020000001320205000100000612000000000004100020100000000000000000001000000002200000100000001000001020000000000020000000000000001000010300060000010000000000070100003000000000000020000000000001000010000104000000000000000000101000100000001401000000000000000000000000000100010000000000000000000000000400020000000002002300010000000000040000041000200005100000000000001000000000100000203010000000000000000000000000001006000100000000000000300100001000100254200000000000101100040000000020000010000050000000501000000000101020000000010000000003000000000200000102100000000204007000000200010000033000000000061000000000000000000000000000000000100001000001000000013000000003000000000002000000000000010001000000000000000000020010000020000000100001000000000000001000103000000000000000000020020000001000000000100001000000000000000020220200200000001001000010100000000200000000000001000002000000011000000000101200000000000000000000000000000000000000100130000000000000000000100000120000300040000000002000000000000000000000100000000070000100000000301000000401200002020000000000601030001510000000000000110100000000000000000050000000010000100000000000000000100022000100000101054010001000000000000001000001000000002000000000100000000000021000001000002000000000100000000000000000000951000000100000000000000000000000000102000200000000000000010000010000000000100002000000000000000000010000000000000010000000010000000102010000000010520100000021010100000030000000000000000100000001000000022000330051000000100000000000040003020000010000020000100000013000000102020000000050000000020010000000000000000101200C000100000001200400000000010000001000000000100010000000001000001000000100000000010000000004000000002000013102000100000000000000000000000600000010000000000000020000000000001000000000030000000000000020000000001000001000000000010000003002000003000200070001001003030010000000003000000000000020000006000000000000000011000000010000200000000000500000000000000020500000000003000000000000000004000030000100000000103000001000000000000200002004200000020000000030000000000000000000000002000100000000000000002000000000000000010020101000000005250000010000000000023010000001000000000000500002001000123100030011000020001310600000000000021000023000003000000000000000001000000000000220200000000004040000020201000000010201000000000020000400010000050000000000000000000000010000020000000000000000000000000000000000102000010000000000000000000000002010000200200000000000000000000000000100000000000000000200400000000010000000000000000000000000000000010000200300000000000100110000000000000000000000000010000030000001000000000010000010200013000000000000200000001000001200010000000010000000000001000000000000100000000410000040000001000100010000100000002001010000000000000000001000000000000010000000000000000000000002000000000001100001000000001010000000000000002200000000004000000000000100010000000000600000000100300000000000000000000010000003000000000000000000310000010100006000010001000000000000001010101000100000000000000000000000000000201000000000000000700010000030000000000000021000000000000000001020000000030000100001000000000000000000000004010100000000000000000000004000000040100000040100100001000000000300000100000000010010000300000200000000000001302000000000000000000100100000400030000001001000100100002300000004030000002010000220100000000000002000000010010000000003010500000000300000000005020102000200000000000000020100000000000000000000000011000000023000000000010000101000000000000010020040200040000020000004000020000000001000000000100000200000010000000000030100010001000000100000000000600400000000002000000000000132000000900010000000030021400000000004100006000304000000000000010000106000001300020000'";
5515+
5516+
service
5517+
.exec_query(
5518+
&format!("INSERT INTO s.Orders (a, b, hll) VALUES (1, 10, {s}), \
5519+
(2, 20, {d}), \
5520+
(1, 10, {d}), \
5521+
(2, 30, {s}), \
5522+
(1, 10, {d}), \
5523+
(2, 20, {s}) \
5524+
",
5525+
s = sparse,
5526+
d = dense
5527+
),
5528+
)
5529+
.await
5530+
.unwrap();
5531+
5532+
let res = service
5533+
.exec_query("SELECT a, b, cardinality(merge(hll)) FROM s.Orders GROUP BY 1, 2 ORDER BY 1, 2")
5534+
.await
5535+
.unwrap();
5536+
5537+
assert_eq!(
5538+
to_rows(&res),
5539+
[
5540+
[
5541+
TableValue::Int(1),
5542+
TableValue::Int(10),
5543+
TableValue::Int(657),
5544+
],
5545+
[
5546+
TableValue::Int(2),
5547+
TableValue::Int(20),
5548+
TableValue::Int(657),
5549+
],
5550+
[
5551+
TableValue::Int(2),
5552+
TableValue::Int(30),
5553+
TableValue::Int(2),
5554+
],
5555+
]
5556+
);
5557+
5558+
}
5559+
55005560
async fn aggregate_index_hll(service: Box<dyn SqlClient>) {
55015561
service.exec_query("CREATE SCHEMA s").await.unwrap();
55025562
service

rust/cubestore/cubestore/src/metastore/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ impl AggregateFunction {
639639
},
640640
Self::MERGE => match col_type {
641641
ColumnType::HyperLogLog(_) => true,
642+
ColumnType::Bytes => true,
642643
_ => false,
643644
},
644645
}

0 commit comments

Comments
 (0)