diff --git a/expression/builtin_time_vec.go b/expression/builtin_time_vec.go index 529d0e47b8668..f5558aa20c770 100644 --- a/expression/builtin_time_vec.go +++ b/expression/builtin_time_vec.go @@ -1877,12 +1877,11 @@ func (b *builtinHourSig) vecEvalInt(input *chunk.Chunk, result *chunk.Column) er result.ResizeInt64(n, false) result.MergeNulls(buf) i64s := result.Int64s() - ds := buf.GoDurations() for i := 0; i < n; i++ { if result.IsNull(i) { continue } - i64s[i] = int64(ds[i].Hours()) + i64s[i] = int64(buf.GetDuration(i, int(types.UnspecifiedFsp)).Hour()) } return nil } diff --git a/expression/integration_test.go b/expression/integration_test.go index 0bfa1008381e9..b558fe2148b1c 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -9284,6 +9284,19 @@ func (s *testIntegrationSuite) TestConstPropNullFunctions(c *C) { tk.MustQuery("select * from t2 where t2.i2=((select count(1) from t1 where t1.i1=t2.i2))").Check(testkit.Rows("1 0.1")) } +func (s *testIntegrationSuite) TestIssue28643(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(a time(4));") + tk.MustExec("insert into t values(\"-838:59:59.000000\");") + tk.MustExec("insert into t values(\"838:59:59.000000\");") + tk.MustExec("set tidb_enable_vectorized_expression = on;") + tk.MustQuery("select hour(a) from t;").Check(testkit.Rows("838", "838")) + tk.MustExec("set tidb_enable_vectorized_expression = off;") + tk.MustQuery("select hour(a) from t;").Check(testkit.Rows("838", "838")) +} + func (s *testIntegrationSuite) TestIssue29244(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test")