mihaibudiu commented on PR #4193:
URL: https://github.com/apache/calcite/pull/4193#issuecomment-2660027904

   In general, the result of double addition aggregation depends on the order 
in which the numbers are processed, whereas the addition of decimals gives 
always the same result. 
   
   It's true that this can only happen for very large integers, since double 
has 53 bits of mantissa. So any integer value which requires less than 53 bits 
will be represented exactly, and if all intermediate addition results are less 
than 53 bits the result will be deterministic and exact; the only imprecision 
will be produced by the final division. The result of division in FP and 
DECIMAL can also be slightly different. In general for financial-type 
computations you should always use DECIMAL.
   
   Your formula depends on the number of input values, which is not known when 
you compile the SQL program. Calcite is statically-typed, so it has to choose 
the type at compile-time.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to