Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Feb 4, 2025
1 parent e2f4e37 commit ea41169
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 15 deletions.
16 changes: 1 addition & 15 deletions go/test/endtoend/vtgate/vitess_tester/join/join.test
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,5 @@ values (1, 1),
-- wait_authoritative t1
-- wait_authoritative t2
-- wait_authoritative t3
select 42
from t1
join t2 on t1.id = t2.t1_id
join t3 on t1.id = t3.id
where t1.name
or t2.id
or t3.name;

# Complex query that requires hash join underneath a memory sort and ordered aggregate
select 1
from t1
join t2 on t1.id = t2.t1_id
join t4 on t4.col = t2.id
left join (select t4.col, count(*) as count from t4 group by t4.col) t3 on t3.col = t2.id
where t1.id IN (1, 2)
group by t2.id, t4.col;
select t1.name, t2.t1_id from t1, t2 where t1.id = t2.id;
43 changes: 43 additions & 0 deletions go/vt/vtgate/executor_select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,49 @@ func TestSimpleJoin(t *testing.T) {
testQueryLog(t, executor, logChan, "TestExecute", "SELECT", "select u1.id, u2.id from `user` as u1 join `user` as u2 where u1.id = 1 and u2.id = 3", 2)
}

func TestSimpleValuesJoin(t *testing.T) {
executor, sbc1, sbc2, _, ctx := createExecutorEnv(t)
logChan := executor.queryLogger.Subscribe("Test")
defer executor.queryLogger.Unsubscribe(logChan)

sbc1.Queries = nil
sbc2.Queries = nil

sbc1.SetResults([]*sqltypes.Result{
sqltypes.MakeTestResult(
sqltypes.MakeTestFields("id|name", "int64|varchar"),
"1|toto",
"2|tata",
),
})

sbc2.SetResults([]*sqltypes.Result{
sqltypes.MakeTestResult(
sqltypes.MakeTestFields("id|id|offset", "int64|int64|int64"),
"1|toto|0",
"2|tata|1",
),
})

sql := "select u1.id, u2.id from user u1 join user u2 where u1.name = u2.name"
session := &vtgatepb.Session{
TargetString: "@primary",
}

_, err := executorExec(ctx, executor, session, sql, nil)
require.NoError(t, err)
wantQueries := []*querypb.BoundQuery{{
Sql: "select u1.id from `user` as u1 where u1.id = 1",
BindVariables: map[string]*querypb.BindVariable{},
}}
utils.MustMatch(t, wantQueries, sbc1.Queries)
wantQueries = []*querypb.BoundQuery{{
Sql: "select u2.id from `user` as u2 where u2.id = 3",
BindVariables: map[string]*querypb.BindVariable{},
}}
utils.MustMatch(t, wantQueries, sbc2.Queries)
}

func TestJoinComments(t *testing.T) {
executor, sbc1, sbc2, _, ctx := createExecutorEnv(t)
logChan := executor.queryLogger.Subscribe("Test")
Expand Down

0 comments on commit ea41169

Please sign in to comment.