Skip to content

Commit

Permalink
fix case
Browse files Browse the repository at this point in the history
Signed-off-by: guo-shaoge <[email protected]>
  • Loading branch information
guo-shaoge committed May 28, 2024
1 parent 0531b23 commit d52311d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/expression/integration_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 27,
shard_count = 26,
deps = [
"//pkg/config",
"//pkg/domain",
Expand Down
11 changes: 0 additions & 11 deletions pkg/expression/integration_test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3032,14 +3032,3 @@ func TestIssue43527(t *testing.T) {
"SELECT @total := @total + d FROM (SELECT d FROM test) AS temp, (SELECT @total := b FROM test) AS T1 where @total >= 100",
).Check(testkit.Rows("200", "300", "400", "500"))
}

func TestNegFloatConvertToUnsigned(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t0")
tk.MustExec("create table t0(c0 tinyint(1) unsigned not null )")
tk.MustExec("insert into t0 values (1)")
tk.MustQuery("select * from t0 where case 0 when (t0.c0)>(-1.194192591e9) then null else 1 end;").Check(testkit.Rows("1"))
tk.MustQuery("select (t0.c0)>(-1.194192591e9) from t0;").Check(testkit.Rows("1"))
}
30 changes: 30 additions & 0 deletions tests/integrationtest/r/expression/cast.result
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,33 @@ select null as a union all select 'a' as a;
a
NULL
a
drop table if exists t0;
create table t0(c0 tinyint(1) unsigned not null );
insert into t0 values (1);
select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end;
c0
1
select t0.c0 > -1.194192591e9 from t0;
t0.c0 > -1.194192591e9
1
select t0.c0 < -1.194192591e9 from t0;
t0.c0 < -1.194192591e9
0
select -1.194192591e9 > t0.c0 from t0;
-1.194192591e9 > t0.c0
0
select -1.194192591e9 < t0.c0 from t0;
-1.194192591e9 < t0.c0
1
select t0.c0 > 1.194192591e9 from t0;
t0.c0 > 1.194192591e9
0
select t0.c0 < 1.194192591e9 from t0;
t0.c0 < 1.194192591e9
1
select 1.194192591e9 > t0.c0 from t0;
1.194192591e9 > t0.c0
1
select 1.194192591e9 < t0.c0 from t0;
1.194192591e9 < t0.c0
0
14 changes: 14 additions & 0 deletions tests/integrationtest/t/expression/cast.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ select cast(cast('14:15' as time) as year) = YEAR(CURDATE());
explain select null as a union all select 'a' as a;
--sorted_result
select null as a union all select 'a' as a;

# TestNegFloatConvertToUnsigned
drop table if exists t0;
create table t0(c0 tinyint(1) unsigned not null );
insert into t0 values (1);
select * from t0 where case 0 when t0.c0 > -1.194192591e9 then null else 1 end;
select t0.c0 > -1.194192591e9 from t0;
select t0.c0 < -1.194192591e9 from t0;
select -1.194192591e9 > t0.c0 from t0;
select -1.194192591e9 < t0.c0 from t0;
select t0.c0 > 1.194192591e9 from t0;
select t0.c0 < 1.194192591e9 from t0;
select 1.194192591e9 > t0.c0 from t0;
select 1.194192591e9 < t0.c0 from t0;

0 comments on commit d52311d

Please sign in to comment.