Skip to content

Simplify CASE WHEN false THEN ... #17590

Closed

Description

@alamb

Is your feature request related to a problem or challenge?

One form of Case statements look like

CASE 
  WHEN <expr> THEN <expr>
  WHEN <expr> THEN <expr>
  ...
   ELSE
END

As suggested by @geoffreyclaude in #17448 (comment)

Any WHEN false will never execute and thus can be removed from the

For example

CASE 
  WHEN false THEN 1  -- never executed
  ELSE 2  
END

Could be simplified to

2

Likewise

CASE 
  WHEN x=y THEN 1 
  WHEN false THEN 2  -- never executed
  ELSE 3  
END

Could be simplified to

CASE 
  WHEN x=y THEN 1 
  ELSE 3  
END

Describe the solution you'd like

I would like to implement the simplification above

Describe alternatives you've considered

I think we can just extend the existing rules for CASE simplification here:

An example is In #17450 where @EeshanBembi implemented a new CASE simplification

Additional context

_No response_¯

Activity

  1. added theissue type on Sep 16, 2025
  2. alamb commented on Sep 16, 2025

    @alamb
    ContributorAuthor

    Since this is well specified and has an example PR I think it is a good first issue

  3. SidChaudhary7 commented on Sep 16, 2025

    @SidChaudhary7

    take

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions