Skip to content

Commit

Permalink
fix bigint handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nbenn committed Nov 24, 2023
1 parent 6cdfcdf commit 94da3df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions R/dbFetch_AdbiResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ dbFetch_AdbiResult <- function(res, n = -1, ...) {
meta(res, "ptyp") <- arrow_ptype(res)
}

ret <- meta(res, "ptyp")
ret <- as_data_frame(meta(res, "ptyp"), res@bigint)

} else {

Expand Down Expand Up @@ -170,7 +170,7 @@ converter_to <- function(to) {
typs <- vapply(cols, `[[`, character(1L), "type")
bint <- typs == "int64"

ptype[bint] <- rep(list(bint_ptype), sum(bint))
ptype[bint] <- list(bint_ptype)

ptype
}
Expand All @@ -181,6 +181,7 @@ as_data_frame <- function(x, bigint) {
to <- converter_to(bigint)

if (inherits(x, "nanoarrow_array_stream")) {
on.exit(x$release())
nanoarrow::convert_array_stream(x, to)
} else if (inherits(x, "nanoarrow_array")) {
nanoarrow::convert_array(x, to)
Expand All @@ -192,22 +193,24 @@ as_data_frame <- function(x, bigint) {
get_data_batch <- function(x, what = c("next", "rest")) {

if (is.null(meta(x, "data"))) {
return(as.data.frame(meta(x, "ptyp"), x@bigint))
}

if (identical(match.arg(what), "rest")) {
res <- meta(x, "ptyp")

} else if (identical(match.arg(what), "rest")) {

meta(x, "ptyp") <- arrow_ptype(x)

res <- as.data.frame(meta(x, "data"), x@bigint)
res <- meta(x, "data")

meta(x, "data") <- NULL
meta(x, "has_completed") <- TRUE

return(res)
} else {

res <- get_next_batch(x)
}

as.data.frame(get_next_batch(x), x@bigint)
as_data_frame(res, x@bigint)
}

get_next_batch <- function(x) {
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-DBItest.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if (identical(Sys.getenv("NOT_CRAN"), "true") &&
"send_statement_stale_warning",
"send_query_only_one_result_set",
"send_statement_only_one_result_set",
"data_logical",
"data_raw", # apache/arrow-adbc#1004
"data_64_bit_numeric_warning", # apache/arrow-adbc#1005
"data_64_bit_lossless", # apache/arrow-adbc#1005
Expand Down

0 comments on commit 94da3df

Please sign in to comment.