-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
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
SQL: floats precision and scale corrections #40357
Labels
:Analytics/SQL
SQL querying
Comments
Pinging @elastic/es-search |
Rectification: for PRECISION, the ODBC documents the values to use for the floating types as column size (as 3rd column in the type information API) as follows:
|
costin
added a commit
to costin/elasticsearch
that referenced
this issue
Mar 26, 2019
costin
added a commit
that referenced
this issue
Mar 27, 2019
costin
added a commit
that referenced
this issue
Mar 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is proposing to change the reported
MAXIMUM_SCALE
,MINIMUM_SCALE
and potentiallyPRECISION
values inSYS TYPES
answer.MINIMUM_SCALE
The floats are not variable precision in ES. Furthermore, according to ODBC's SQLGetTypeInfo,
If a data type has a fixed scale, the MINIMUM_SCALE and MAXIMUM_SCALE columns both contain this value.
So I believe MINIMUM_SCALE should contain the same values as MAXIMUM_SCALE.MAXIMUM_SCALE
Currently its value is 16. However, it's precision is half of that of a FLOAT. So it should be adjusted down accordingly. (Also, see example[1] below.)
Currently 19, probably suggested by it being backed up by a signed long, whose precision is 19. However, this is handled as a floating point (probably double?), so it's scale should be adjusted accordingly. (Also, see example[2] below.)
PRECISION
This column has currently the same values as the MAXIMUM_SCALE. Its value however is that of the maximum number of digits (whole and fractional plus dot and sign or exponential), so it should be in any case greater than that. Current implementation of operations - like addition, for instance - is consistent with the currently reported value, in that it truncates the result. But this truncation seems incorrect, as it's effectively reducing the type's scale. (Also, see example[3] below.). IMO, both the reported precision and operations should be corrected. (There might be Java readily-available calculations for the maximum precision of floats, like for C/C++.)
Example:
Above one can see that:
For the PRECISION point[3]:
In this case, the PRECISION seems kept, but the scale (and thus float data type's precision, in non-SQL talk) is diminished, the type's reported scale then no longer being correct.
An alternative implementation:
The text was updated successfully, but these errors were encountered: