Dustin Smith created SPARK-62342:
------------------------------------

             Summary: Sum of large BigInt values can overflow without an error
                 Key: SPARK-62342
                 URL: https://issues.apache.org/jira/browse/SPARK-62342
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 5.0.0
            Reporter: Dustin Smith


Adding large {{BigInt}} or {{BigInteger}} values can give a wrong answer with 
no error, whether ANSI mode is on or off. If a Dataset has a {{BigInt}} column 
with 500000000000000000 and then 9000000000000000000 in one partition, {{sum}} 
returns -8946744073709551616 instead of 9500000000000000000. {{avg}} is off too.

{{Decimal}} adds two values as longs when both are stored as a long. That is 
safe below 10^18, and the other setters stick to that limit. 
{{set(BigInteger)}} doesn't: it stores anything that fits in a long, so the 
addition can wrap around.

Fix: apply the same limit in {{set(BigInteger)}}.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to