You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scalar subquery returning no rows is incorrectly marked non-nullable #24513
A scalar subquery that returns no rows evaluates to NULL, even if its projected expression is non-nullable. DataFusion instead derives the scalar subquery's nullability from its projected field.
As a result, a zero-row scalar subquery with a non-nullable projection can produce a NULL value in a schema declared non-nullable. It can also cause expression simplification to incorrectly fold IS NULL to false.
To Reproduce
Run:
cargo run --quiet -p datafusion-cli -- -q -c \ "SELECT (SELECT 1 WHERE FALSE) AS scalar_value;"cargo run --quiet -p datafusion-cli -- -q -c \ "SELECT (SELECT 1 WHERE FALSE) IS NULL AS is_null;"
The first query fails because the result contains a null value while its schema declares the field non-nullable. The second query returns false because the optimizer simplifies the predicate using that incorrect nullability.
Expected behavior
The first query should return one row containing NULL, and the second query should return true:
Activity
fix: account for empty scalar subqueries in nullability (apache#24516)
fix: preserve nullability for non-empty scalar subqueries (apache#24534)
fix: account for empty scalar subqueries in nullability (apache#24516)
fix: account for empty scalar subqueries in nullability (apache#24516)