Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 22 additions & 0 deletions enginetest/join_planning_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ type joinPlanScript struct {
}

var JoinPlanningTests = []joinPlanScript{
{
// https://github.com/dolthub/dolt/issues/9977
name: "filters with anti and semi joins",
setup: []string{
"CREATE table xy (x int, y int, primary key(x,y));",
"insert into xy values (1,0), (2,1), (0,2), (3,3);",
},
tests: []JoinPlanTest{
{
q: "select * from xy where x > 0 and x not in (select 999 union select 2 union select 3) order by x",
types: nil,
exp: []sql.Row{
{1, 0},
},
},
{
q: "select * from xy where x > 0 and x not in (select 999) and x in (select 888 union select 777)",
types: []plan.JoinType{plan.JoinTypeLeftOuter},
exp: []sql.Row{},
},
},
},
{
name: "filter pushdown through join uppercase name",
setup: []string{
Expand Down
151 changes: 91 additions & 60 deletions enginetest/queries/tpch_plans.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sql/analyzer/pushdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func updateFilterNode(ctx *sql.Context, a *Analyzer, node *plan.Filter, filters
}

// push filters into joinChild
if joinChild, ok := node.Child.(*plan.JoinNode); ok && !joinChild.Op.IsOuter() {
if joinChild, ok := node.Child.(*plan.JoinNode); ok && !joinChild.Op.IsOuter() && !joinChild.Op.IsAnti() {
a.Log("pushing filters into join node")
if joinChild.Op.IsCross() {
return plan.NewInnerJoin(joinChild.Left(), joinChild.Right(), expression.JoinAnd(unhandled...))
Expand Down