wForget commented on issue #14771:
URL: https://github.com/apache/datafusion/issues/14771#issuecomment-2703080393

   > No for data fusion, as it is matching with the Postgres behavior. But Yes 
for comet to be matched with Spark
   
   In spark, the `/` operation will be converted to `double/decimal` division, 
so only integral divide operation of `Long.MinValue div -1` has inconsistent 
behavior.
   
   test like:
   
   ```
      test("COMET-1412: test smallest signed integer value div -1") {
       Seq[(String, Any)](
         // ("short", Short.MinValue),
         // ("int", Int.MinValue),
         ("long", Long.MinValue)
        // ("double", Double.MinValue)
       ).foreach { case (t, v) =>
         withTable("t1") {
           sql(s"create table t1(c1 $t, c2 short) using parquet")
           sql(s"insert into t1 values($v, -1)")
           withSQLConf(CometConf.COMET_ENABLED.key -> "false "){
             sql("select c1 div c2, c1 div -1 from t1 order by c1").show()
           }
           withSQLConf(CometConf.COMET_ENABLED.key -> "true "){
             sql("select c1 div c2, c1 div -1 from t1 order by c1").show()
           }
         }
       }
     }
   ```
   
   result of vanilla spark:
   
   ```
   +--------------------+--------------------+
   |         (c1 div c2)|         (c1 div -1)|
   +--------------------+--------------------+
   |-9223372036854775808|-9223372036854775808|
   +--------------------+--------------------+
   ```
   
   error on comet:
   
   ```
   org.apache.comet.CometNativeException: Arithmetic overflow: Overflow 
happened on: -9223372036854775808 / -1
        at org.apache.comet.Native.executePlan(Native Method)
   ```


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

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