Skip to content

Commit

Permalink
[no-release-notes] test for left join bug (#2840)
Browse files Browse the repository at this point in the history
* [no-release-notes] test for left join bug

* additional test

* more tests
  • Loading branch information
max-hoffman authored Feb 4, 2025
1 parent 67aa2a4 commit d8430eb
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions enginetest/join_op_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,56 @@ var DefaultJoinOpTests = []joinOpTest{
},
},
},
{
name: "left join null-filter",
setup: [][]string{
setup.MydbData[0],
{
"CREATE table xy (x int primary key, y int, z int, index y_idx(y));",
"CREATE table ab (a int primary key, b int, c int);",
"insert into xy values (1,0,0), (2,null,1), (3,2,2),(4,2,3);",
"insert into ab values (0,1,0), (1,2,1), (2,3,2), (3,4,3);",
},
},
tests: []JoinOpTests{
{
Query: "select /*+ JOIN_ORDER(ab,xy) */ x from xy left join ab on x = a and z = 5 where a is null order by x ",
Expected: []sql.Row{{1}, {2}, {3}, {4}},
},
{
Query: "select /*+ JOIN_ORDER(xy,ab) */ x from xy left join ab on x = a and z = 5 where a is null order by x ",
Expected: []sql.Row{{1}, {2}, {3}, {4}},
},
// partial return
{
Query: "select /*+ JOIN_ORDER(ab,xy) */ x from xy left join ab on x = a and z = 1 where a is null order by x ",
Expected: []sql.Row{{1}, {3}, {4}},
},
{
Query: "select /*+ JOIN_ORDER(xy,ab) */ x from xy left join ab on x = a and z in (1,2) where a is null order by x ",
Expected: []sql.Row{{1}, {4}},
},
},
},
{
name: "type conversion panic bug",
setup: [][]string{
setup.MydbData[0],
{
"create table xy (x int primary key, y int, z varchar(10), key (y,z));",
"insert into xy values (0,0,'0'), (1,1,'1');",
"create table ab (a int primary key, b int);",
"insert into ab values (0,0), (1,1);",
},
},
tests: []JoinOpTests{
{
// the literal z should be internally cast to the appropriate string type
Query: "select /*+ JOIN_ORDER(ab,xy) */ count(*) from xy join ab on y = a and z = 0",
Expected: []sql.Row{{1}},
},
},
},
{
name: "partial key null lookup join indexes",
setup: [][]string{
Expand Down

0 comments on commit d8430eb

Please sign in to comment.