Function sql::plan::transform_expr::try_simplify_quantified_comparisons[][src]

pub fn try_simplify_quantified_comparisons(expr: &mut HirRelationExpr)
Expand description

Rewrites quantified comparisons into simpler EXISTS operators.

Note that this transformation is only valid when the expression is used in a context where the distinction between FALSE and NULL is immaterial, e.g., in a WHERE clause or a CASE condition, or when the inputs to the comparison are non-nullable. This function is careful to only apply the transformation when it is valid to do so.

WHERE (SELECT any() FROM ) => WHERE EXISTS(SELECT * FROM WHERE )

WHERE (SELECT all() FROM ) => WHERE NOT EXISTS(SELECT * FROM WHERE (NOT ) OR IS NULL)

See Section 3.5 of “Execution Strategies for SQL Subqueries” by M. Elhemali, et al.