We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacOS 14.4 arm64
+---------+--------+----------+ | version | build | platform | +---------+--------+----------+ | 14.4 | 23E214 | darwin | +---------+--------+----------+
5.11.0 (master)
Distributed queries return seemingly wrong results due to numerical precision issues when converting numbers to strings.
For example, the query: SELECT ROUND(3.531, 2) as num; returns "distributed_query_433":[{"num":"3.5299999999999998"}]
SELECT ROUND(3.531, 2) as num;
"distributed_query_433":[{"num":"3.5299999999999998"}]
The correct result can be achieved by using a cast: SELECT CAST(ROUND(3.531, 2) as text) as num; returns "distributed_query_435":[{"num":"3.53"}]
SELECT CAST(ROUND(3.531, 2) as text) as num;
"distributed_query_435":[{"num":"3.53"}]
This issue is not directly seen in osqueryi but can be simulated like:
SELECT printf("%.16f", ROUND(3.531, 2)) as num; +--------------------+ | num | +--------------------+ | 3.5299999999999990 | +--------------------+
SQLite REAL type only stores 15 significant digits, so trying to represent a number with more than 16 digits will cause this issue.
In osquery core, the conversion from double to string should limit precision to 16 digits (15 significant + 1 non-significant)
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Bug report
What operating system and version are you using?
MacOS 14.4 arm64
What version of osquery are you using?
5.11.0 (master)
What steps did you take to reproduce the issue?
Distributed queries return seemingly wrong results due to numerical precision issues when converting numbers to strings.
For example, the query:
SELECT ROUND(3.531, 2) as num;
returns"distributed_query_433":[{"num":"3.5299999999999998"}]
The correct result can be achieved by using a cast:
SELECT CAST(ROUND(3.531, 2) as text) as num;
returns"distributed_query_435":[{"num":"3.53"}]
This issue is not directly seen in osqueryi but can be simulated like:
Root cause
SQLite REAL type only stores 15 significant digits, so trying to represent a number with more than 16 digits will cause this issue.
In osquery core, the conversion from double to string should limit precision to 16 digits (15 significant + 1 non-significant)
The text was updated successfully, but these errors were encountered: