2010YOUY01 opened a new issue, #11313:
URL: https://github.com/apache/datafusion/issues/11313

   ### Is your feature request related to a problem or challenge?
   
   Now `CASE` expression's `WHEN` branch can accept numbers, maybe it's better 
to let it only accept boolean due to:
   1. Avoid confusion caused by implicit conversion
   2. PostgreSQL's convention is only accept `BOOLEAN` (IIRC datafusion tries 
to follow postgres conventions when possible)
   
   ### Table creation
   ```
   create table t1 (v1 int);
   insert into t1 values (-1),(0),(1),(null);
   ```
   ### DataFusion Example
   ```
   > select count(case when v1 then 1 else null end) from t1;
   +----------------------------------------------------+
   | count(CASE WHEN t1.v1 THEN Int64(1) ELSE NULL END) |
   +----------------------------------------------------+
   | 2                                                  |
   +----------------------------------------------------+
   ```
   ### PostgreSQL Example
   ```
   postgres=# select count(case when v1 then 1 else null end) from t1;
   ERROR:  argument of CASE/WHEN must be type boolean, not type integer
   LINE 1: select count(case when v1 then 1 else null end) from t1;
   ```
   
   ### 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