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
The 54.0.0 upgrade guide's CASE workaround is rewritten to a conjunction #25136
Currently, CASE is rewritten into a conjunction, so a THEN branch that can fail runs on rows the WHEN excluded.
To Reproduce
CREATEVIEWtASSELECT*FROM (VALUES ('1'), ('abc'), ('2')) s(s);
CREATEVIEWuASSELECT*FROM (VALUES ('1'), ('2')) s(s);
EXPLAIN SELECT s FROM t WHERE CASE WHEN s ~ '^[0-9]+$' THEN CAST(s ASINT) >0 ELSE false END;
-- FilterExec predicate: CAST(column1 AS Int32) > 0 AND column1 ~ ^[0-9]+$SELECT s FROM t WHERE s ='zzz'AND CAST(s ASINT) >0;
-- no rows, no error, so an all-false left operand does skip the castSELECT s FROM u WHERE CASE WHEN s ~ '^[0-9]+$' THEN CAST(s ASINT) >0 ELSE false END;
-- 1 and 2, so it only bites once a row would fail the THEN branchSELECT s FROM t WHERE CASE WHEN s ~ '^[0-9]+$' THEN CAST(s ASINT) >0 ELSE false END;
-- Cast error: Cannot cast string 'abc' to value of Int32 type
Expected behavior
1 and 2. CAST(s AS INT) runs only on rows where the WHEN held.
Additional context
The 54.0.0 upgrade guide prescribes this exact CASE, "which has standardized short-circuit semantics".
Activity
emecii commentedon Sep 10, 2026
take
fix: preserve short-circuit evaluation in Boolean CASE simplification (…
fix: preserve short-circuit evaluation in Boolean CASE simplification (…