We can optimize some case block for nullability. Namely, when in WHEN block we check for a column being null, we can guarantee that for any subsequent WHEN/THEN/ELSE clauses that column is not null.
CASE
WHEN a = NULL
THEN f1(a, b) -- can't optimize here
WHEN c = NULL
THEN f2(a, b, c) -- a can't be null here
ELSE f3(a, b, c) -- a and c can't be null here
END
we need to make sure we properly handle the nullable column information in case of nested CASE blocks
e.g. if f2 is some complicated CASE block that itself checks for b == null we don't want that to bleed into the ELSE block that tests for f3