Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: optimize non-nullable column information in CASE blocks #25977

Open
maumar opened this issue Sep 11, 2021 · 0 comments
Open

Query: optimize non-nullable column information in CASE blocks #25977

maumar opened this issue Sep 11, 2021 · 0 comments

Comments

@maumar
Copy link
Contributor

maumar commented Sep 11, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants