Skip to content

Commit

Permalink
executor: use EncodeKey to encode groupkey in StreamAggExec (#49974)
Browse files Browse the repository at this point in the history
close #49902
  • Loading branch information
wshwsh12 authored Jan 3, 2024
1 parent ca04759 commit 596276b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/executor/internal/vecgroupchecker/vec_group_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ func (e *VecGroupChecker) SplitIntoGroups(chk *chunk.Chunk) (isFirstGroupSameAsP
return false, err
}
}
e.firstGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx.TimeZone(), e.firstGroupKey, e.firstRowDatums...)
e.firstGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx.TimeZone(), e.firstGroupKey, e.firstRowDatums...)
err = e.ctx.GetSessionVars().StmtCtx.HandleError(err)
if err != nil {
return false, err
}

e.lastGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx.TimeZone(), e.lastGroupKey, e.lastRowDatums...)
e.lastGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx.TimeZone(), e.lastGroupKey, e.lastRowDatums...)
err = e.ctx.GetSessionVars().StmtCtx.HandleError(err)
if err != nil {
return false, err
Expand Down
15 changes: 15 additions & 0 deletions tests/integrationtest/r/executor/issues.result
Original file line number Diff line number Diff line change
Expand Up @@ -850,3 +850,18 @@ c
2
2147483647
set @@sql_mode = default;
set @@tidb_max_chunk_size = 32;
drop table if exists t, s;
CREATE TABLE `t` (`c` char(1)) COLLATE=utf8_general_ci ;
insert into t values("V"),("v");
insert into t values("V"),("v"),("v");
CREATE TABLE `s` (`col_61` int);
insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
SELECT /*+ stream_agg()*/ count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;
count(`t`.`c`)
170
SELECT count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;
count(`t`.`c`)
170
set @@tidb_max_chunk_size = default;
15 changes: 14 additions & 1 deletion tests/integrationtest/t/executor/issues.test
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,17 @@ set @@sql_mode = '';
insert into t select round(cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(18,12)) * cast('88888899999999999888888888888888888888888888888888888.11111111111111111111' as decimal(42,18)) );
show warnings;
select * from t;
set @@sql_mode = default;
set @@sql_mode = default;

# TestIssue49902
set @@tidb_max_chunk_size = 32;
drop table if exists t, s;
CREATE TABLE `t` (`c` char(1)) COLLATE=utf8_general_ci ;
insert into t values("V"),("v");
insert into t values("V"),("v"),("v");
CREATE TABLE `s` (`col_61` int);
insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);
SELECT /*+ stream_agg()*/ count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;
SELECT count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;
set @@tidb_max_chunk_size = default;

0 comments on commit 596276b

Please sign in to comment.