You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/07/23 08:53:43 UTC

[GitHub] [spark] cloud-fan commented on issue #21599: [SPARK-26218][SQL] Overflow on arithmetic operations returns incorrect result

cloud-fan commented on issue #21599: [SPARK-26218][SQL] Overflow on arithmetic operations returns incorrect result
URL: https://github.com/apache/spark/pull/21599#issuecomment-514117978
 
 
   For overflow checking, I do think `Math.addExtract` is better, although it doesn't work for byte/short and float/double.
   1. For byte/short, we add them as int(this is how java adds 2 bytes), and then check if it exceeds the range of byte/short, and then cast it back to byte/short. I think this should be faster than checking the signum.
   2. For float/double, I'm not sure we can check overflow by signum. And float/double can be `Infinity` at the beginning, so I don't really know how to detect overflows. Can you check other databases?
   
   For the interpreted version, we can implement custom `Numeric` in places like `ByteType#numeric` and add overflow check.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org