Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor, tests: move more test cases from join_test.go and write_test.go to integrationtest #47420

Merged
merged 4 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion executor/test/jointest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 14,
shard_count = 11,
deps = [
"//config",
"//meta/autoid",
Expand Down
53 changes: 0 additions & 53 deletions executor/test/jointest/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,6 @@ import (
"github.com/stretchr/testify/require"
)

func TestJoinPanic2(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set sql_mode = 'ONLY_FULL_GROUP_BY'")
tk.MustExec("drop table if exists events")
tk.MustExec("create table events (clock int, source int)")
tk.MustQuery("SELECT * FROM events e JOIN (SELECT MAX(clock) AS clock FROM events e2 GROUP BY e2.source) e3 ON e3.clock=e.clock")
err := tk.ExecToErr("SELECT * FROM events e JOIN (SELECT clock FROM events e2 GROUP BY e2.source) e3 ON e3.clock=e.clock")
require.Error(t, err)

// Test for PR 18983, use to detect race.
tk.MustExec("use test")
tk.MustExec("drop table if exists tpj1,tpj2;")
tk.MustExec("create table tpj1 (id int, b int, unique index (id));")
tk.MustExec("create table tpj2 (id int, b int, unique index (id));")
tk.MustExec("insert into tpj1 values (1,1);")
tk.MustExec("insert into tpj2 values (1,1);")
tk.MustQuery("select tpj1.b,tpj2.b from tpj1 left join tpj2 on tpj1.id=tpj2.id where tpj1.id=1;").Check(testkit.Rows("1 1"))
}

func TestJoinInDisk(t *testing.T) {
origin := config.RestoreFunc()
defer origin()
Expand Down Expand Up @@ -906,38 +885,6 @@ func TestJoinLeak(t *testing.T) {
tk.MustExec("set @@tidb_hash_join_concurrency=5")
}

func TestSubqueryInJoinOn(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t1 (id int)")
tk.MustExec("create table t2 (id int)")
tk.MustExec("insert into t1 values (1)")
tk.MustExec("insert into t2 values (1)")

err := tk.ExecToErr("SELECT * FROM t1 JOIN t2 on (t2.id < all (SELECT 1))")
require.Error(t, err)
}

func TestIssue15850JoinNullValue(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustQuery("SELECT * FROM (select null) v NATURAL LEFT JOIN (select null) v1;").Check(testkit.Rows("<nil>"))
require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount())

tk.MustExec("drop table if exists t0;")
tk.MustExec("drop view if exists v0;")
tk.MustExec("CREATE TABLE t0(c0 TEXT);")
tk.MustExec("CREATE VIEW v0(c0) AS SELECT NULL;")
tk.MustQuery("SELECT /*+ HASH_JOIN(v0) */ * FROM v0 NATURAL LEFT JOIN t0;").Check(testkit.Rows("<nil>"))
require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount())
tk.MustQuery("SELECT /*+ MERGE_JOIN(v0) */ * FROM v0 NATURAL LEFT JOIN t0;").Check(testkit.Rows("<nil>"))
require.Equal(t, uint16(0), tk.Session().GetSessionVars().StmtCtx.WarningCount())
}

func TestNullEmptyAwareSemiJoin(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down
4 changes: 1 addition & 3 deletions executor/test/writetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"write_test.go",
],
flaky = True,
shard_count = 44,
shard_count = 30,
deps = [
"//br/pkg/lightning/mydump",
"//config",
Expand All @@ -21,10 +21,8 @@ go_test(
"//planner/core",
"//session",
"//sessionctx",
"//sessionctx/variable",
"//sessiontxn",
"//store/mockstore",
"//table",
"//table/tables",
"//testkit",
"//types",
Expand Down
597 changes: 0 additions & 597 deletions executor/test/writetest/write_test.go

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions tests/integrationtest/r/executor/join.result
Original file line number Diff line number Diff line change
Expand Up @@ -633,3 +633,40 @@ a1 a2 b1 b2 c1 c2
1 2 1 3 NULL NULL
2 2 2 3 NULL NULL
3 2 NULL NULL 3 4
set sql_mode = 'ONLY_FULL_GROUP_BY';
drop table if exists events;
create table events (clock int, source int);
SELECT * FROM events e JOIN (SELECT MAX(clock) AS clock FROM events e2 GROUP BY e2.source) e3 ON e3.clock=e.clock;
clock source clock
SELECT * FROM events e JOIN (SELECT clock FROM events e2 GROUP BY e2.source) e3 ON e3.clock=e.clock;
Error 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'executor__join.e2.clock' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
drop table if exists tpj1,tpj2;
create table tpj1 (id int, b int, unique index (id));
create table tpj2 (id int, b int, unique index (id));
insert into tpj1 values (1,1);
insert into tpj2 values (1,1);
select tpj1.b,tpj2.b from tpj1 left join tpj2 on tpj1.id=tpj2.id where tpj1.id=1;
b b
1 1
set sql_mode = default;
drop table if exists t1;
drop table if exists t2;
create table t1 (id int);
create table t2 (id int);
insert into t1 values (1);
insert into t2 values (1);
SELECT * FROM t1 JOIN t2 on (t2.id < all (SELECT 1));
Error 1105 (HY000): ON condition doesn't support subqueries yet
SELECT * FROM (select null) v NATURAL LEFT JOIN (select null) v1;
NULL
NULL
drop table if exists t0;
drop view if exists v0;
CREATE TABLE t0(c0 TEXT);
CREATE VIEW v0(c0) AS SELECT NULL;
SELECT /*+ HASH_JOIN(v0) */ * FROM v0 NATURAL LEFT JOIN t0;
c0
NULL
SELECT /*+ MERGE_JOIN(v0) */ * FROM v0 NATURAL LEFT JOIN t0;
c0
NULL
Loading