Skip to content
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

Suggest testing the edge case behavior of 64-bit integer handling more #412

Open
MichaelChirico opened this issue Mar 27, 2025 · 0 comments

Comments

@MichaelChirico
Copy link
Contributor

connect_bigint_numeric = function(ctx) {
#' - `"numeric"`: always return as `numeric`, silently round
con <- local_connection(ctx, bigint = "numeric")
res <- dbGetQuery(con, "SELECT 10000000000")
expect_type(res[[1]], "double")
expect_equal(res[[1]], 1e10)
},
#
connect_bigint_character = function(ctx) {
#' - `"character"`: always return the decimal representation as `character`
con <- local_connection(ctx, bigint = "character")
res <- dbGetQuery(con, "SELECT 10000000000")
expect_type(res[[1]], "character")
expect_equal(res[[1]], "10000000000")
},
#
connect_bigint_integer64 = function(ctx) {
#' - `"integer64"`: return as a data type that can be coerced using
#' [as.integer()] (with warning on overflow), [as.numeric()]
#' and [as.character()]
con <- local_connection(ctx, bigint = "integer64")
res <- dbGetQuery(con, "SELECT 10000000000")
expect_warning(expect_true(is.na(as.integer(res[[1]]))))
expect_equal(as.numeric(res[[1]]), 1e10)
expect_equal(as.character(res[[1]]), "10000000000")
},

It should be possible to stress-test backends' handling of 64-bit integers better.

The first thing I would look for is how they handle non-representable-as-64-bit-double integers, I.e., the large % of integers between 2^55 and 2^63 that are not exact multiples of the right powers of 2.

Next, we should try and establish a standard on how NULL and -2^63 are handled (since {bit64} reserves that as NA_integer64_).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant