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

   ### Describe the bug
   
   Initially reported in Comet 
https://github.com/apache/datafusion-comet/issues/1412
   
   ```
   $datafusion-cli                                             
   DataFusion CLI v44.0.0
   > create table t1(c1 int, c2 int);
   0 row(s) fetched. 
   Elapsed 0.016 seconds.
   
   > insert into t1 values(-2147483648, -1);
   +-------+
   | count |
   +-------+
   | 1     |
   +-------+
   1 row(s) fetched. 
   Elapsed 0.027 seconds.
   
   > select c1 % c2 from t1;
   Arrow error: Arithmetic overflow: Overflow happened on: -2147483648 % -1
   ```
   
   It looks Postgres returns 0 for this case
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   `-2147483648 % -1` should return `0`
   
   ### Additional context
   
   rust -2147483648 + -1 also overflows
   ```
   >> let r = -2147483648 + -1;
   [arithmetic_overflow] Error: this arithmetic operation will overflow
      ╭─[command:1:1]
      │
    1 │ let r = -2147483648 + -1;
      │         ────────┬───────  
      │                 ╰───────── attempt to compute `i32::MIN + -1_i32`, 
which would overflow
   ───╯
   ```
   But DataFusion is allowing the overflow
   ```
   > select c1 + c2 from t1;
   +---------------+
   | t1.c1 + t1.c2 |
   +---------------+
   | 2147483647    |
   +---------------+
   1 row(s) fetched. 
   Elapsed 0.010 seconds.
   ```
   
   So we should be able to do similar handling?


-- 
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