diff --git a/NAMESPACE b/NAMESPACE index 8d6210b6d..bc7c5c94d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) diff --git a/NEWS.md b/NEWS.md index b581754f1..b398aae5d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). diff --git a/R/eager.R b/R/eager.R new file mode 100644 index 000000000..9c4ff6f66 --- /dev/null +++ b/R/eager.R @@ -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 diff --git a/R/zzz.R b/R/zzz.R index ea1fabf6f..fcb44886b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -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")