Skip to content

Commit

Permalink
expression: Fix wrong result of microsecond function in vectorized (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Feb 9, 2022
1 parent 269c040 commit be7a95d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions expression/builtin_time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,12 +964,11 @@ func (b *builtinMicroSecondSig) vecEvalInt(input *chunk.Chunk, result *chunk.Col
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] % time.Second) / time.Microsecond)
i64s[i] = int64(buf.GetDuration(i, int(types.UnspecifiedFsp)).MicroSecond())
}
return nil
}
Expand Down
13 changes: 13 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9944,3 +9944,16 @@ func (s *testIntegrationSuite) TestIssue27831(c *C) {
tk.MustExec("insert into t values(\"a\", \"a\", 1, 1);")
tk.MustQuery("select /*+ inl_hash_join(t1) */ * from t t1 right join t t2 on t1.a=t2.b and t1.a= t2.c and t1.d=t2.d;").Check(testkit.Rows("a a 1 1 a a 1 1"))
}

func (s *testIntegrationSuite) TestIssue29244(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(\"-700:10:10.123456111\");")
tk.MustExec("insert into t values(\"700:10:10.123456111\");")
tk.MustExec("set tidb_enable_vectorized_expression = on;")
tk.MustQuery("select microsecond(a) from t;").Check(testkit.Rows("123500", "123500"))
tk.MustExec("set tidb_enable_vectorized_expression = off;")
tk.MustQuery("select microsecond(a) from t;").Check(testkit.Rows("123500", "123500"))
}

0 comments on commit be7a95d

Please sign in to comment.