alamb opened a new issue, #17590:
URL: https://github.com/apache/datafusion/issues/17590

   ### Is your feature request related to a problem or challenge?
   
   ### Is your feature request related to a problem or challenge?
   
   
   One form of Case statements look like
   ```sql
   CASE 
     WHEN <expr> THEN <expr>
     WHEN <expr> THEN <expr>
     ...
      ELSE
   END
   ```
   
   As suggested by @geoffreyclaude  in 
https://github.com/apache/datafusion/issues/17448#issuecomment-3293549174
   
   
   Any `WHEN false` will never execute and thus can be removed from the
   
   For example
   ```sql
   CASE 
     WHEN false THEN 1  -- never executed
     ELSE 2  
   END
   ```
   
   Could be simplified to 
   
   ```sql
   2
   ```
   
   Likewise
   
   ```sql
   CASE 
     WHEN x=y THEN 1 
     WHEN false THEN 2  -- never executed
     ELSE 3  
   END
   ```
   
   Could be simplified to 
   
   ```sql
   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:
   
   
https://github.com/apache/datafusion/blob/ec4413e7d7b41c381c98eda909e5ab650be4c5e5/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L1398-L1400
   
   An example is In https://github.com/apache/datafusion/pull/17450 where 
@EeshanBembi implemented a new CASE simplification
   
   
   ### Additional context
   
   _No response_¯
   
   ### Describe the solution you'd like
   
   _No response_
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to