Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move auto_copy() to avoid error for misplaced copy argument #309

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions R/anti_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
anti_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches = c("na", "never")) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# https://github.com/duckdb/duckdb/issues/6597
na_matches <- check_na_matches(na_matches, error_call = error_call)
Expand All @@ -12,7 +11,7 @@ anti_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches
rel_try(list(name = "anti_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, na_matches = na_matches)),
"No restrictions" = FALSE,
{
out <- rel_join_impl(x, y, by, "anti", na_matches, error_call = error_call)
out <- rel_join_impl(x, y, by, copy, "anti", na_matches, error_call = error_call)
return(out)
}
)
Expand Down
3 changes: 1 addition & 2 deletions R/full_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
full_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = NULL, na_matches = c("na", "never"), multiple = "all", relationship = NULL) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(list(name = "full_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, relationship = relationship)),
"No implicit cross joins for full_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "full", na_matches, suffix, keep, error_call)
out <- rel_join_impl(x, y, by, copy, "full", na_matches, suffix, keep, error_call)
return(out)
}
)
Expand Down
3 changes: 1 addition & 2 deletions R/inner_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
inner_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = NULL, na_matches = c("na", "never"), multiple = "all", unmatched = "drop", relationship = NULL) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(list(name = "inner_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
"No implicit cross joins for inner_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "inner", na_matches, suffix, keep, error_call)
out <- rel_join_impl(x, y, by, copy, "inner", na_matches, suffix, keep, error_call)
return(out)
}
)
Expand Down
5 changes: 5 additions & 0 deletions R/join.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ rel_join_impl <- function(
x,
y,
by,
copy,
join,
na_matches,
suffix = c(".x", ".y"),
keep = NULL,
error_call = caller_env()
) {
# Forcing copy might be an error, fall back in this case
# Examples: joyn, gtsummary, crosshap
y <- auto_copy(x, y, copy = copy)

mutating <- !(join %in% c("semi", "anti"))

if (mutating) {
Expand Down
3 changes: 1 addition & 2 deletions R/left_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
left_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = NULL, na_matches = c("na", "never"), multiple = "all", unmatched = "drop", relationship = NULL) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(list(name = "left_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
"No implicit cross joins for left_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "left", na_matches, suffix, keep, error_call)
out <- rel_join_impl(x, y, by, copy, "left", na_matches, suffix, keep, error_call)
return(out)
}
)
Expand Down
3 changes: 1 addition & 2 deletions R/right_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
right_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = NULL, na_matches = c("na", "never"), multiple = "all", unmatched = "drop", relationship = NULL) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# Our implementation
rel_try(list(name = "right_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, keep = keep, na_matches = na_matches, multiple = multiple, unmatched = unmatched, relationship = relationship)),
"No implicit cross joins for right_join()" = is_cross_by(by),
{
out <- rel_join_impl(x, y, by, "right", na_matches, suffix, keep, error_call)
out <- rel_join_impl(x, y, by, copy, "right", na_matches, suffix, keep, error_call)
return(out)
}
)
Expand Down
3 changes: 1 addition & 2 deletions R/semi_join.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
semi_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches = c("na", "never")) {
check_dots_empty0(...)
error_call <- caller_env()
y <- auto_copy(x, y, copy = copy)

# https://github.com/duckdb/duckdb/issues/6597
na_matches <- check_na_matches(na_matches, error_call = error_call)
Expand All @@ -12,7 +11,7 @@ semi_join.duckplyr_df <- function(x, y, by = NULL, copy = FALSE, ..., na_matches
rel_try(list(name = "semi_join", x = x, y = y, args = list(by = if (!is.null(by) && !is_cross_by(by)) as_join_by(by), copy = copy, na_matches = na_matches)),
"No restrictions" = FALSE,
{
out <- rel_join_impl(x, y, by, "semi", na_matches, error_call = error_call)
out <- rel_join_impl(x, y, by, copy, "semi", na_matches, error_call = error_call)
return(out)
}
)
Expand Down
Loading