findepi commented on PR #13590:
URL: https://github.com/apache/datafusion/pull/13590#issuecomment-2508177283

   > * The IEEE-754 basic arithmetic operations are reproducible.
   > ...
   > * Floating-point arithmetic is not associative.
   
   These two points imply that a database's Floating-point arithmetic results 
are not supposed to be reproducible.
   Taking `sum(a)` for example -- a database is free to parallelize the work if 
it wishes so, and thus input values may end up being added on the CPU in 
different order or in different groups altogether. This is emphasized by the 
fact that in SQL, the input tables have no intrinsic ordering.
   
   Let's consider an example
   ```sql
   CREATE TABLE doubles(a Float64);
   INSERT INTO doubles VALUES (1e30);
   INSERT INTO doubles VALUES (-1e30);
   INSERT INTO doubles VALUES (1);
   INSERT INTO doubles VALUES (-1);
   ```
   
   If we now run
   ```sql
   SELECT sum(a) FROM doubles;
   ```
   
   database can return 0, 1 or -1.
   
   
   
   
   
   
   
   
   
   
   


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


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

Reply via email to