Skip to content

Commit

Permalink
Merge pull request #50 from karoliskascenas/patch-2 (fixes #49)
Browse files Browse the repository at this point in the history
Make copy_to size limit configurable
  • Loading branch information
ianmcook authored Feb 6, 2021
2 parents 7da147e + 55f3537 commit 9a8e3eb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# implyr (development version)

* Fixed bugs in table creation (#47, @karoliskascenas)
* Allow user to set `copy_to()` size limit with option `implyr.copy_to_size_limit` (#49, @karoliskascenas)
* Added more SQL translations
* Fixed a DBI identifier quoting problem causing errors with dbplyr 2.0.0 (#48)

Expand Down
16 changes: 9 additions & 7 deletions R/src_impala.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,12 @@ tbl.src_impala <- function(src, from, ...) {
#' @name copy_to
#' @description
#' \code{copy_to} inserts the contents of a local data frame into a new Impala
#' table. \code{copy_to} currently only supports very small data frames (1000 or
#' fewer row/column positions). It uses the SQL \code{INSERT ... VALUES()}
#' technique, which is not suitable for loading large amounts of data.
#' table. \code{copy_to} is intended to be used only with very small data
#' frames. It uses the SQL \code{INSERT ... VALUES()} technique, which is not
#' suitable for loading large amounts of data. By default, this function will
#' throw an error if you attempt to copy a data frame with more than 1000
#' row/column positions. You can increase this limit at your own risk by setting
#' the \link{option} \code{implyr.copy_to_size_limit} to a higher number.
#'
#' This package does not provide tools for loading larger amounts of local data
#' into Impala tables. This is because Impala can query data stored in several
Expand Down Expand Up @@ -337,13 +340,12 @@ copy_to.src_impala <-
file_format = NULL,
...) {
# don't try to insert large data frames with INSERT ... VALUES()
if (prod(dim(df)) > 1e3L) {
# TBD: consider whether to make this limit configurable, possibly using
# options with the pkgconfig package
if (prod(dim(df)) > getOption("implyr.copy_to_size_limit", 1e3L)) {
stop(
"Data frame ",
name,
" is too large. copy_to currently only supports very small data frames.",
" is too large. ",
"implyr::copy_to() is only for use with very small data frames.",
call. = FALSE
)
}
Expand Down
31 changes: 23 additions & 8 deletions man/copy_to.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a8e3eb

Please sign in to comment.