Repository navigation
Read an integral JSON float as an integer in json_get_int - #147
Merged
Merged
Conversation
`json_get_int` was NULL for a JSON number written as a float, even with an integral value such as `1.0` or `2e3`, and so was `CAST(j -> 'k' AS BIGINT)`. A float with an integral value in the `i64` range now gives that integer. A fractional value is not rounded or truncated, and a value outside the `i64` range, NaN or infinity stays NULL. Integers and numeric strings are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
==========================================
+ Coverage 94.00% 94.12% +0.12%
==========================================
Files 18 18
Lines 1902 1925 +23
Branches 1902 1925 +23
==========================================
+ Hits 1788 1812 +24
Misses 64 64
+ Partials 50 49 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Sep 29, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
json_get_int, and soCAST(j -> 'k' AS BIGINT)and::int, returns NULL for a JSON number written as a float, even when its value is an integer:JSON has one number type, and many serializers write whole numbers as
1.0. Other engines convert1.0to1.With this change a JSON float with an integral value in the
i64range gives that integer, and-0.0gives0. These stay NULL:1.5is not rounded or truncated)i64range (for example9.223372036854776e18, which is 2^63, and1e300)Integers, big integer literals and numeric strings behave as before. The string
"1.0"is still NULL.Tests cover the range bounds,
-0.0, exponents, fractional values, and the direct call, theCASTand the->forms.