Skip to content

Commit eb1a79b

Browse files
committed
Wrap nullable hoisted filter in IsTrue
1 parent 83d2fda commit eb1a79b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sql/analyzer/hoist_filters.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ func recurseSubqueryForOuterFilters(n sql.Node, a *Analyzer, corr sql.ColSet) (s
131131
newCorr = newCorr.Union(outOfScope)
132132
keepFilters = append(keepFilters, e)
133133
} else {
134-
// nothing tethers the subquery to this scope
134+
// nothing tethers the subquery or filter expression to this scope
135+
if sq == nil && e.IsNullable() {
136+
// If a filter expression has been hoisted out of a subquery, it needs to be made not nullable. This
137+
// is because filters that evaluate to null in an Exists or In subquery are treated the same as
138+
// false.
139+
e = expression.NewIsTrue(e)
140+
}
135141
hoistFilters = append(hoistFilters, e)
136142
}
137143
}

0 commit comments

Comments
 (0)