Skip to content

Commit

Permalink
Warning for old eager methods
Browse files Browse the repository at this point in the history
Fixes #77
  • Loading branch information
hadley committed Jun 27, 2019
1 parent 36ba4a5 commit 5c3e325
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
17 changes: 17 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(anti_join,data.table)
S3method(anti_join,dtplyr_step)
S3method(arrange,dtplyr_step)
S3method(as.data.frame,dtplyr_step)
Expand All @@ -9,32 +10,48 @@ S3method(as_tibble,dtplyr_step)
S3method(auto_copy,dtplyr_step)
S3method(collect,dtplyr_step)
S3method(dim,dtplyr_step)
S3method(distinct,data.table)
S3method(distinct,dtplyr_step)
S3method(do,data.table)
S3method(do,dtplyr_step)
S3method(full_join,data.table)
S3method(full_join,dtplyr_step)
S3method(group_by,data.table)
S3method(group_by,dtplyr_step)
S3method(group_size,dtplyr_step)
S3method(groups,dtplyr_step)
S3method(head,dtplyr_step)
S3method(inner_join,data.table)
S3method(inner_join,dtplyr_step)
S3method(left_join,data.table)
S3method(left_join,dtplyr_step)
S3method(mutate,data.table)
S3method(mutate,dtplyr_step)
S3method(n_groups,dtplyr_step)
S3method(print,dtplyr_step)
S3method(pull,dtplyr_step)
S3method(rename,data.table)
S3method(rename,dtplyr_step)
S3method(right_join,data.table)
S3method(right_join,dtplyr_step)
S3method(same_src,dtplyr_step)
S3method(sample_frac,data.table)
S3method(sample_frac,dtplyr_step)
S3method(sample_n,data.table)
S3method(sample_n,dtplyr_step)
S3method(select,data.table)
S3method(select,dtplyr_step)
S3method(semi_join,data.table)
S3method(semi_join,dtplyr_step)
S3method(show_query,dtplyr_step)
S3method(slice,data.table)
S3method(slice,dtplyr_step)
S3method(summarise,data.table)
S3method(summarise,dtplyr_step)
S3method(tail,dtplyr_step)
S3method(tbl_vars,dtplyr_step)
S3method(tbl_vars,foo)
S3method(transmute,data.table)
S3method(transmute,dtplyr_step)
S3method(ungroup,dtplyr_step)
S3method(union_all,dtplyr_step)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
extremely inefficient so offered little of data.table's impressive speed,
and was used by very few people.

* dtplyr provides methods for data.tables that warning you that they use the
data frame implementation and you should use `lazy_dt()` (#77)

* Joins now pass `...` on to data table's merge method (#41).

* Convert from lazyeval to tidy eval (@christophsax).
Expand Down
133 changes: 133 additions & 0 deletions R/eager.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# nocov begin

warn_data_frame_method <- function() {
warn(strwrap(paste0(
"You are using a dplyr method on a raw data.table, which will call the ",
"data frame implementation, and is likely to be inefficient. \n\n",
"To suppress this message, either generate a data.table translation ",
"with `lazy_dt()` or convert to a data frame or tibble with ", "
`as.data.frame()`/`as_tibble()`."
)))
}

# Single table ------------------------------------------------------------

#' @export
distinct.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
do.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

# exported onLoad
filter.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
group_by.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
mutate.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
rename.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
sample_frac.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
sample_n.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
summarise.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
select.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
slice.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
summarise.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}


#' @export
transmute.data.table <- function(.data, ...) {
warn_data_frame_method()
NextMethod()
}


# Two-table ---------------------------------------------------------------

#' @export
left_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
right_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
inner_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
full_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
semi_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

#' @export
anti_join.data.table <- function(x, y, ...) {
warn_data_frame_method()
NextMethod()
}

# nocov end
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# nocov start
.onLoad <- function(...) {
register_s3_method("dplyr", "filter", "data.table")

register_s3_method("dplyr", "filter", "dtplyr_step")
register_s3_method("dplyr", "intersect", "dtplyr_step")
register_s3_method("dplyr", "setdiff", "dtplyr_step")
Expand Down

0 comments on commit 5c3e325

Please sign in to comment.