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

groupingsets handling int64 does not need workaround anymore #6480

Open
jangorecki opened this issue Sep 6, 2024 · 2 comments
Open

groupingsets handling int64 does not need workaround anymore #6480

jangorecki opened this issue Sep 6, 2024 · 2 comments

Comments

@jangorecki
Copy link
Member

# workaround for rbindlist fill=TRUE on integer64 #1459
int64.cols = vapply_1b(empty, inherits, "integer64")
int64.cols = names(int64.cols)[int64.cols]
if (length(int64.cols) && !requireNamespace("bit64", quietly=TRUE))
stopf("Using integer64 class columns require to have 'bit64' package installed.") # nocov
int64.by.cols = intersect(int64.cols, by)
# aggregate function called for each grouping set
aggregate.set = function(by.set) {
r = if (length(.SDcols)) x[, eval(jj), by.set, .SDcols=.SDcols] else x[, eval(jj), by.set]
if (id) {
# integer bit mask of aggregation levels: http://www.postgresql.org/docs/9.5/static/functions-aggregate.html#FUNCTIONS-GROUPING-TABLE
# 3267: strtoi("", base = 2L) output apparently unstable across platforms
i_str = paste(c("1", "0")[by %chin% by.set + 1L], collapse="")
set(r, j = "grouping", value = if (nzchar(i_str)) strtoi(i_str, base=2L) else 0L)
}
if (length(int64.by.cols)) {
# workaround for rbindlist fill=TRUE on integer64 #1459
missing.int64.by.cols = setdiff(int64.by.cols, by.set)
if (length(missing.int64.by.cols)) r[, (missing.int64.by.cols) := bit64::as.integer64(NA)]
}
r
}

#1459 has been resolved, therefore existing workaround can be removec

@Anirban166
Copy link
Member

Is this still valid? (I see more work around that part being done for the file)

If it is still omittable, maybe add the OP's case as a test after removal:

require(bit64)
test(2296, merge(data.table(id = c(1, 2)), data.table(id = 1, value = as.integer64(1)), by = "id", all.x = TRUE), data.table(id = c(1, 2), value = c(as.integer64(1), NA_integer64)))

@jangorecki
Copy link
Member Author

Afair this workaround was not removed there

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

2 participants