fix: to_i64 and to_u64 function support rounded numeric conversion#100
Merged
sundy-li merged 3 commits intodatabendlabs:mainfrom Mar 27, 2026
Merged
fix: to_i64 and to_u64 function support rounded numeric conversion#100sundy-li merged 3 commits intodatabendlabs:mainfrom
to_i64 and to_u64 function support rounded numeric conversion#100sundy-li merged 3 commits intodatabendlabs:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts integer conversion semantics for JSON numbers by distinguishing exact integer extraction (as_*) from rounded numeric coercion (to_*), and updates scalar conversion helpers and tests accordingly.
Changes:
- Restored
Number::{as_i128,as_i64,as_u64}to exact-integer-only behavior and introducedNumber::{to_i128,to_i64,to_u64}for rounded conversion. - Updated
RawJsonb::{to_i64,to_u64}to round numeric values before conversion and added parsing support for stringified floats. - Expanded integration/unit tests to cover exact-vs-rounded behavior for numeric conversions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/it/functions.rs | Adds/updates integration tests for exact integer extraction and rounded coercions (including stringified floats). |
| src/number.rs | Implements exact integer extraction helpers and new rounded conversion APIs for Number, plus supporting tests. |
| src/functions/scalar.rs | Updates RawJsonb scalar conversion docs and changes to_{i64,u64} to use the new rounded conversion + string-float parsing helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sundy-li
approved these changes
Mar 27, 2026
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.
This PR refines integer conversion behavior for JSON numbers by separating exact integer extraction from rounded numeric coercion.
Changes
Number::as_i128,Number::as_i64, andNumber::as_u64to exact-integer semantics.Number::to_i128,Number::to_i64, andNumber::to_u64for rounded numeric conversion.RawJsonb::to_i64andRawJsonb::to_u64to round numeric values before conversion.RawJsonb::to_i64andRawJsonb::to_u64.