Skip to content

Query: optimize CASE statement - remove conditions that are never hit #18935

@maumar

Description

@maumar
CASE
        WHEN CAST(0 AS bit) THEN x
        ELSE y
    END

we can simply remove the WHEN block since it's condition is never met so the result would be just y

If all the WHEN blocks have been removed and there is no ELSE condition we can return NULL

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions