diff --git a/expression/builtin_time.go b/expression/builtin_time.go index b188d573ef7fa..0bb3475fd5e2b 100644 --- a/expression/builtin_time.go +++ b/expression/builtin_time.go @@ -39,6 +39,7 @@ import ( "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/chunk" "github.com/pingcap/tidb/util/logutil" + "github.com/pingcap/tidb/util/parser" "github.com/pingcap/tipb/go-tipb" "github.com/tikv/client-go/v2/oracle" "go.uber.org/zap" @@ -5773,6 +5774,16 @@ func (b *builtinAddStringAndStringSig) evalString(row chunk.Row) (result string, } return "", true, err } + + check := arg1Str + _, check, err = parser.Number(parser.Space0(check)) + if err == nil { + check, err = parser.Char(check, '-') + if strings.Compare(check, "") != 0 && err == nil { + return "", true, nil + } + } + if isDuration(arg0) { result, err = strDurationAddDuration(sc, arg0, arg1) if err != nil { diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index 703d6f38160d5..5bedae12c0e1c 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -927,6 +927,7 @@ func TestAddTimeSig(t *testing.T) { {"2018-08-16 20:21:01", "00:00:00.000001", "2018-08-16 20:21:01.000001"}, {"1", "xxcvadfgasd", ""}, {"xxcvadfgasd", "1", ""}, + {"2020-05-13 14:01:24", "2020-04-29 05:11:19", ""}, } fc := funcs[ast.AddTime] for _, c := range tbl {