-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from duckdblabs/f-94-group-rest
- Loading branch information
Showing
18 changed files
with
336 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by 02-duckplyr_df-methods.R | ||
#' @export | ||
group_indices.duckplyr_df <- function(.data, ...) { | ||
# Our implementation | ||
rel_try( | ||
# Always fall back to dplyr | ||
"No relational implementation for group_indices()" = TRUE, | ||
{ | ||
return(out) | ||
} | ||
) | ||
|
||
# dplyr forward | ||
group_indices <- dplyr$group_indices.data.frame | ||
out <- group_indices(.data, ...) | ||
return(out) | ||
|
||
# dplyr implementation | ||
if (dots_n(...) > 0) { | ||
lifecycle::deprecate_warn( | ||
"1.0.0", "group_indices(... = )", | ||
details = "Please `group_by()` first", | ||
always = TRUE | ||
) | ||
.data <- group_by(.data, ...) | ||
} | ||
|
||
# .Call(`dplyr_group_indices`, .data, group_rows(.data)) | ||
} | ||
|
||
duckplyr_group_indices <- function(.data, ...) { | ||
try_fetch( | ||
.data <- as_duckplyr_df(.data), | ||
error = function(e) { | ||
testthat::skip(conditionMessage(e)) | ||
} | ||
) | ||
out <- group_indices(.data, ...) | ||
class(out) <- setdiff(class(out), "duckplyr_df") | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by 02-duckplyr_df-methods.R | ||
#' @export | ||
group_nest.duckplyr_df <- function(.tbl, ..., .key = "data", keep = FALSE) { | ||
# Our implementation | ||
rel_try( | ||
# Always fall back to dplyr | ||
"No relational implementation for group_nest()" = TRUE, | ||
{ | ||
return(out) | ||
} | ||
) | ||
|
||
# dplyr forward | ||
group_nest <- dplyr$group_nest.data.frame | ||
out <- group_nest(.tbl, ..., .key = .key, keep = keep) | ||
return(out) | ||
|
||
# dplyr implementation | ||
if (dots_n(...)) { | ||
group_nest_impl(group_by(.tbl, ...), .key = .key, keep = keep) | ||
} else { | ||
tibble(!!.key := list(.tbl)) | ||
} | ||
} | ||
|
||
duckplyr_group_nest <- function(.tbl, ...) { | ||
try_fetch( | ||
.tbl <- as_duckplyr_df(.tbl), | ||
error = function(e) { | ||
testthat::skip(conditionMessage(e)) | ||
} | ||
) | ||
out <- group_nest(.tbl, ...) | ||
class(out) <- setdiff(class(out), "duckplyr_df") | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by 02-duckplyr_df-methods.R | ||
#' @export | ||
group_split.duckplyr_df <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) { | ||
# Our implementation | ||
rel_try( | ||
# Always fall back to dplyr | ||
"No relational implementation for group_split()" = TRUE, | ||
{ | ||
return(out) | ||
} | ||
) | ||
|
||
# dplyr forward | ||
group_split <- dplyr$group_split.data.frame | ||
out <- group_split(.tbl, ..., .keep = .keep, keep = keep) | ||
return(out) | ||
|
||
# dplyr implementation | ||
if (!missing(keep)) { | ||
lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )", always = TRUE) | ||
.keep <- keep | ||
} | ||
data <- group_by(.tbl, ...) | ||
group_split_impl(data, .keep = .keep) | ||
} | ||
|
||
duckplyr_group_split <- function(.tbl, ...) { | ||
try_fetch( | ||
.tbl <- as_duckplyr_df(.tbl), | ||
error = function(e) { | ||
testthat::skip(conditionMessage(e)) | ||
} | ||
) | ||
out <- group_split(.tbl, ...) | ||
class(out) <- setdiff(class(out), "duckplyr_df") | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by 02-duckplyr_df-methods.R | ||
#' @export | ||
group_trim.duckplyr_df <- function(.tbl, .drop = group_by_drop_default(.tbl)) { | ||
# Our implementation | ||
rel_try( | ||
# Always fall back to dplyr | ||
"No relational implementation for group_trim()" = TRUE, | ||
{ | ||
return(out) | ||
} | ||
) | ||
|
||
# dplyr forward | ||
group_trim <- dplyr$group_trim.data.frame | ||
out <- group_trim(.tbl, .drop) | ||
return(out) | ||
|
||
# dplyr implementation | ||
.tbl | ||
} | ||
|
||
duckplyr_group_trim <- function(.tbl, ...) { | ||
try_fetch( | ||
.tbl <- as_duckplyr_df(.tbl), | ||
error = function(e) { | ||
testthat::skip(conditionMessage(e)) | ||
} | ||
) | ||
out <- group_trim(.tbl, ...) | ||
class(out) <- setdiff(class(out), "duckplyr_df") | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by 02-duckplyr_df-methods.R | ||
#' @export | ||
n_groups.duckplyr_df <- function(x) { | ||
# Our implementation | ||
rel_try( | ||
# Always fall back to dplyr | ||
"No relational implementation for n_groups()" = TRUE, | ||
{ | ||
return(out) | ||
} | ||
) | ||
|
||
# dplyr forward | ||
n_groups <- dplyr$n_groups.data.frame | ||
out <- n_groups(x) | ||
return(out) | ||
|
||
# dplyr implementation | ||
nrow(group_data(x)) | ||
} | ||
|
||
duckplyr_n_groups <- function(x, ...) { | ||
try_fetch( | ||
x <- as_duckplyr_df(x), | ||
error = function(e) { | ||
testthat::skip(conditionMessage(e)) | ||
} | ||
) | ||
out <- n_groups(x, ...) | ||
class(out) <- setdiff(class(out), "duckplyr_df") | ||
out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
group_indices.data.frame <- function(.data, ...) { | ||
if (dots_n(...) > 0) { | ||
lifecycle::deprecate_warn( | ||
"1.0.0", "group_indices(... = )", | ||
details = "Please `group_by()` first", | ||
always = TRUE | ||
) | ||
.data <- group_by(.data, ...) | ||
} | ||
|
||
.Call(`dplyr_group_indices`, .data, group_rows(.data)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
group_nest.data.frame <- function(.tbl, ..., .key = "data", keep = FALSE) { | ||
if (dots_n(...)) { | ||
group_nest_impl(group_by(.tbl, ...), .key = .key, keep = keep) | ||
} else { | ||
tibble(!!.key := list(.tbl)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
group_split.data.frame <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) { | ||
if (!missing(keep)) { | ||
lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )", always = TRUE) | ||
.keep <- keep | ||
} | ||
data <- group_by(.tbl, ...) | ||
group_split_impl(data, .keep = .keep) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
group_trim.data.frame <- function(.tbl, .drop = group_by_drop_default(.tbl)) { | ||
.tbl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
n_groups.data.frame <- function(x) { | ||
nrow(group_data(x)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git b/R/group_indices.R a/R/group_indices.R | ||
index 48bcf3e..6c1bf15 100644 | ||
--- b/R/group_indices.R | ||
+++ a/R/group_indices.R | ||
@@ -25,7 +25,7 @@ group_indices.duckplyr_df <- function(.data, ...) { | ||
.data <- group_by(.data, ...) | ||
} | ||
|
||
- .Call(`dplyr_group_indices`, .data, group_rows(.data)) | ||
+ # .Call(`dplyr_group_indices`, .data, group_rows(.data)) | ||
} | ||
|
||
duckplyr_group_indices <- function(.data, ...) { |
Oops, something went wrong.