'The native addition, subtraction, multiplication and division in the current sql will cause precision problems on apache iotdb database
Currently, native addition, subtraction, multiplication and division of Float fields on SQL will cause problems with the accuracy of the results, as shown in the following figure. This is mainly due to the fact that there is no special treatment for precision when converting the Float type to the Double type in the program. This problem will not appear when there are no four arithmetic operations, but the problem is obvious when there are four arithmetic operations. enter image description here
Solution 1:[1]
Feel this is not a bug. it is normal
Float +float Result type is inferred to be a double in iOTDB.
This is also same with Spark spark-sql> select cast(cast(10.0 as float)+cast(51.71 as float) as double); 61.709999084472656
spark-sql> explain extended select cast(cast(10.0 as float)+cast(51.71 as float) as double); == Parsed Logical Plan == 'Project [unresolvedalias(cast((cast(10.0 as float) + cast(51.71 as float)) as double), None)] +- OneRowRelation
== Analyzed Logical Plan == CAST((CAST(10.0 AS FLOAT) + CAST(51.71 AS FLOAT)) AS DOUBLE): double Project [cast((cast(10.0 as float) + cast(51.71 as float)) as double) AS CAST((CAST(10.0 AS FLOAT) + CAST(51.71 AS FLOAT)) AS DOUBLE)#11] +- OneRowRelation
== Optimized Logical Plan == Project [61.709999084472656 AS CAST((CAST(10.0 AS FLOAT) + CAST(51.71 AS FLOAT)) AS DOUBLE)#11] +- OneRowRelation
== Physical Plan == *(1) Project [61.709999084472656 AS CAST((CAST(10.0 AS FLOAT) + CAST(51.71 AS FLOAT)) AS DOUBLE)#11] +- *(1) Scan OneRowRelation[]
Solution 2:[2]
Pure numbers need to be enclosed in back quotes. For example:
‘root.giyc3eWpsoa.62.100.1002.**’
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Masmine Mccullough |
| Solution 2 | Cecelia Blackt |
