Skip to content
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
14 changes: 14 additions & 0 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -13439,6 +13439,20 @@ select * from t1 except (
},
},
},
{
// https://github.com/dolthub/dolt/issues/10070
Name: "NOT EXISTS with nullable filter",
SetUpScript: []string{
"CREATE TABLE t0(c0 INT , c1 INT);",
"INSERT INTO t0(c0, c1) VALUES (1, -2);",
},
Assertions: []ScriptTestAssertion{
{
Query: `SELECT * FROM t0 WHERE NOT EXISTS (SELECT 1 FROM (SELECT 1) alias0 WHERE (CASE -1 WHEN t0.c1 THEN false END));`,
Expected: []sql.Row{{1, -2}},
},
},
},
}

var SpatialScriptTests = []ScriptTest{
Expand Down
8 changes: 7 additions & 1 deletion sql/analyzer/hoist_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ func recurseSubqueryForOuterFilters(n sql.Node, a *Analyzer, corr sql.ColSet) (s
newCorr = newCorr.Union(outOfScope)
keepFilters = append(keepFilters, e)
} else {
// nothing tethers the subquery to this scope
// nothing tethers the subquery or filter expression to this scope
if sq == nil && e.IsNullable() {
// If a filter expression has been hoisted out of a subquery, it needs to be made not nullable. This
// is because filters that evaluate to null in an Exists or In subquery are treated the same as
// false.
e = expression.NewIsTrue(e)
}
hoistFilters = append(hoistFilters, e)
}
}
Expand Down