-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
JSON UInt64 as string #114
Comments
I Found "IDataTypeNumber.h" had wrote like this : I guess that's the reason. And they would like to do that for themselves. |
We need to make JSON format compatible with JavaScript.
We are using first variant. Second variant is inappropriate because it will lead to silent loss of precision in most implementations. But it is suitable for some sophisticated JSON implementations. Third variant is inappropriate (in my sense) too, because it will lead to surprising, non obvious behaviour. And to have full support of UInt64, you need to call |
Just to be obvious, Uint32 holds values from 0 to ~ 4 billions, while UInt64 goes from 0 to ~ 18 billion billions. A JavaScript number is a double precision float, so it can store numbers from 0 to 253 (~ 9 million billions) with exact precision, and subsequent numbers up to the UInt64 range (and beyond) with some loss in precision. For example the largest UInt64 number, 18 billion billions, is represented as a JavaScript double with an error of ± 0.00000000000001%. All the other numbers have a smaller error (or no error at all if they are < 9 million billions.) I would argue that for 99.99% of applications, especially JavaScript front-end applications, this level of precision is enough. My opinion is that it would be much more useful to have UInt64 and Int64 values without quotes by default, which includes all the aggregate results such as In the remaining cases (if any) in which the developer really needs to perform exact integer arithmetic on large numbers on the client side, they can always use |
I agree, but only partially. Maybe better to add setting, which will allow to write UInt64 without quotes? |
I think that would be very appropriate. |
PR #126 adds new option that switches "quoted" and unquoted formats of *Int64 numbers. |
…U. (#11001) * DOCSUP-1063 (#114) * added first draft * added translation for force_optimize_skip_unused_shards and fixed anchors * fixes * fixes * fixed alter.md Co-authored-by: Elizaveta Mironyuk <emironyuk@yandex-team.ru> * CLICKHOUSEDOCS-627: Updated templated. * Fixed markup. * CLICKHOUSEDOCS-627: Fixed links. Co-authored-by: Sergei Shtykov <bayonet@yandex-team.ru> Co-authored-by: emironyuk <62014692+emironyuk@users.noreply.github.com> Co-authored-by: Elizaveta Mironyuk <emironyuk@yandex-team.ru>
…_merge_fix Config merge fix
Is there a reason why Int64 and UInt64 are output as string in JSON?
As far as I can tell, JSON does not put a limit on the size of a number, and most implementations use double precision floats, which are a superset of 53 bit integers (which should be enough for most needs, even if the field is 64 bit wide in CH.)
This stringification causes problems in the frontend code, where one needs to call
parseInt()
on almost every value returned by queries. Can I override this setting somewhere?The text was updated successfully, but these errors were encountered: