Skip to content

Commit

Permalink
Merge pull request #130 from robertzk/fix_dplyr_bind_rows_issue
Browse files Browse the repository at this point in the history
Fix an issue with dplyr::bind_rows
  • Loading branch information
robertzk committed Apr 11, 2016
2 parents 91fe8fc + 85a767e commit f943f5a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ before_script:
- Rscript -e 'if (length(find.package("devtools", quiet = TRUE)) == 0L) { install.packages("devtools", repos = "http://cran.rstudio.com") }'
- Rscript -e 'devtools::update_packages("devtools", repos = "http://cran.rstudio.com")'
- Rscript -e 'if (!require("roxygen")) devtools::install_github("klutometis/roxygen")'
- Rscript -e 'if (!require("DBI")) devtools::install_github("rstats-db/DBI")'
- Rscript -e 'if (!require("RPostgres")) devtools::install_github("robertzk/RPostgres@0.1.1")'
- Rscript -e 'devtools::install_github("rstats-db/DBI@ca4e977e7106d5b467b49d202234b0cb7b50d26d")'
- Rscript -e 'devtools::install_github("robertzk/RPostgres@0.1.2")'
- Rscript -e 'if (!require("testthat")) devtools::install_github("hadley/testthat")'
- Rscript -e 'if (!require("testthatsomemore")) devtools::install_github("robertzk/testthatsomemore")'
- Rscript -e 'if (!require("syberiaStructure")) devtools::install_github("robertzk/syberiaStructure")'
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cachemeifyoucan
Type: Package
Title: Cache Me If You Can
Version: 0.2.4
Version: 0.2.4.1
Description: One of the most frustrating parts about being a data scientist
is waiting for data or other large downloads. This package offers a caching
layer for arbitrary functions that relies on a PostgreSQL backend.
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 0.2.4.1
* Re-replaces dplyr::bind_rows with plyr::rbind.fill because
plyr::rbind.fill allows the combination of dataframes with
alike content but different classes (e.g., "FALSE" and FALSE),
which happens due to type coercion the cached data.

# Version 0.2.4
* Implements a blacklist of values that are to be returned but not cached.
* Clean up how `safe_columns` is passed along in the function environment.
Expand Down
13 changes: 11 additions & 2 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,17 @@ execute <- function(fcn_call, keys) {
## Actually compute for the uncached keys
cached_data <- compute_cached_data(fcn_call, cached_keys)

data <- dplyr::bind_rows(uncached_data, cached_data)
class(data) <- "data.frame" # un-dplyr
result <- try({
# Incompatible types could cause an error with bind_rows,
# which rbind.fill will handle gracefully below.
data <- dplyr::bind_rows(uncached_data, cached_data)
class(data) <- "data.frame" # un-dplyr
}, silent = TRUE)

if (is(try, "try-error")) {
data <- plyr::rbind.fill(uncached_data, cached_data)
}

if (fcn_call$force) {
## restore column names using existing cache columns
old_columns <- get_column_names_from_table(fcn_call)
Expand Down

0 comments on commit f943f5a

Please sign in to comment.