Skip to content

Commit

Permalink
Merge pull request #6095 from sundy-li/group-constant
Browse files Browse the repository at this point in the history
fix(groupby): support group by constant string
  • Loading branch information
mergify[bot] authored Jun 21, 2022
2 parents 48135f5 + b6c5615 commit 7b434be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/datablocks/src/kernels/data_block_group_by_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ impl HashMethod for HashMethodSingleString {
) -> Result<Vec<&'a [u8]>> {
debug_assert!(group_columns.len() == 1);
let column = group_columns[0];
let str_column: &StringColumn = Series::check_get(column)?;

// may have constant case
let str_column = Vu8::try_create_viewer(column)?;
let mut values = Vec::with_capacity(rows);
for row in 0..rows {
values.push(str_column.get_data(row));
values.push(str_column.value_at(row));
}
Ok(values)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ NULL 2 3
2 1 []
4 3 [1, 2, 3]
6 5 [4, 5, 6]
10
10
4 changes: 4 additions & 0 deletions tests/suites/0_stateless/03_dml/03_0003_select_group_by.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ INSERT INTO t_array VALUES(1, []),

SELECT max(id), min(id), arr FROM t_array GROUP BY arr ORDER BY arr ASC;

-- group by constant string
select count() from numbers(10) group by 'ab';
select count() from numbers(10) group by to_nullable('ab');

DROP TABLE t_array;

0 comments on commit 7b434be

Please sign in to comment.