Skip to content

Commit

Permalink
cherry pick pingcap#23332 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
Howie59 authored and ti-srebot committed Aug 6, 2021
1 parent 4f919b0 commit e1dac35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func (s *testSuiteAgg) TestOnlyFullGroupBy(c *C) {
tk.MustQuery("select max(a+b) from t")
tk.MustQuery("select avg(a)+1 from t")
tk.MustQuery("select count(c), 5 from t")
// test functinal depend on primary key
// test functional depend on primary key
tk.MustQuery("select * from t group by a")
// test functional depend on unique not null columns
tk.MustQuery("select * from t group by b,d")
Expand Down Expand Up @@ -1203,3 +1203,14 @@ func (s *testSuiteAgg) TestIssue23277(c *C) {
tk.MustQuery("select avg(a) from t group by a").Sort().Check(testkit.Rows("-120.0000", "127.0000"))
tk.MustExec("drop table t;")
}

// https://github.com/pingcap/tidb/issues/23314
func (s *testSuiteAgg) TestIssue23314(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(col1 time(2) NOT NULL)")
tk.MustExec("insert into t1 values(\"16:40:20.01\")")
res := tk.MustQuery("select col1 from t1 group by col1")
res.Check(testkit.Rows("16:40:20.01"))
}
3 changes: 2 additions & 1 deletion expression/builtin_cast_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1296,12 +1296,13 @@ func (b *builtinCastDurationAsStringSig) vecEvalString(input *chunk.Chunk, resul
var isNull bool
sc := b.ctx.GetSessionVars().StmtCtx
result.ReserveString(n)
fsp := b.args[0].GetType().Decimal
for i := 0; i < n; i++ {
if buf.IsNull(i) {
result.AppendNull()
continue
}
res, err = types.ProduceStrWithSpecifiedTp(buf.GetDuration(i, 0).String(), b.tp, sc, false)
res, err = types.ProduceStrWithSpecifiedTp(buf.GetDuration(i, fsp).String(), b.tp, sc, false)
if err != nil {
return err
}
Expand Down

0 comments on commit e1dac35

Please sign in to comment.