diff --git a/pkg/executor/internal/vecgroupchecker/vec_group_checker.go b/pkg/executor/internal/vecgroupchecker/vec_group_checker.go index 65c2707b9722e..3def9059f508f 100644 --- a/pkg/executor/internal/vecgroupchecker/vec_group_checker.go +++ b/pkg/executor/internal/vecgroupchecker/vec_group_checker.go @@ -93,12 +93,12 @@ func (e *VecGroupChecker) SplitIntoGroups(chk *chunk.Chunk) (isFirstGroupSameAsP return false, err } } - e.firstGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, e.firstGroupKey, e.firstRowDatums...) + e.firstGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx, e.firstGroupKey, e.firstRowDatums...) if err != nil { return false, err } - e.lastGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, e.lastGroupKey, e.lastRowDatums...) + e.lastGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx, e.lastGroupKey, e.lastRowDatums...) if err != nil { return false, err } diff --git a/tests/integrationtest/r/executor/issues.result b/tests/integrationtest/r/executor/issues.result index 4001bff307270..93cd6c1f9e20e 100644 --- a/tests/integrationtest/r/executor/issues.result +++ b/tests/integrationtest/r/executor/issues.result @@ -746,3 +746,18 @@ insert into F values (1, 8); select table1.`col_int` as field1, table1.`col_int` as field2 from V as table1 left join F as table2 on table1.`col_int` = table2.`col_int` order by field1, field2 desc limit 2; field1 field2 8 8 +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; diff --git a/tests/integrationtest/t/executor/issues.test b/tests/integrationtest/t/executor/issues.test index 2b078a52e45e5..d644c6c87322c 100644 --- a/tests/integrationtest/t/executor/issues.test +++ b/tests/integrationtest/t/executor/issues.test @@ -557,3 +557,15 @@ create table F (id int primary key, col_int int); insert into F values (1, 8); select table1.`col_int` as field1, table1.`col_int` as field2 from V as table1 left join F as table2 on table1.`col_int` = table2.`col_int` order by field1, field2 desc limit 2; +# 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; \ No newline at end of file