benkrug commented on code in PR #13671: URL: https://github.com/apache/druid/pull/13671#discussion_r1074028863
########## docs/querying/sql-operators.md: ########## @@ -37,6 +37,10 @@ sidebar_label: "Operators" Operators in [Druid SQL](./sql.md) typically operate on one or two values and return a result based on the values. Types of operators in Druid SQL include arithmetic, comparison, logical, and more, as described here. +When performing math operations, Druid uses the integer datatype unless there are double or float values. If double or float values are involved, Druid uses double. Note that the highest precision way to store digits in Druid are 64-bit integers (long) or 64-bit floats (double). In essence, a double can represent 52 binary digits, so Druid may return incorrect results for doubles if the value exceeds 2^52. + +For more information about how Java handles primitive data types and how it may impact the results you get, see [Primitive data types in Java are a matter of precision](https://blogs.oracle.com/javamagazine/post/java-primitive-datatypes-int-float-double). Review Comment: (O.T. but if we had your bigdecimal @paul-rogers, I bet many people would use that instead. Back in my Oracle days, most people I knew, and I, used their DECIMAL datatype, to avoid floating point precision issues.) -- 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]
