dragosmg commented on a change in pull request #12179:
URL: https://github.com/apache/arrow/pull/12179#discussion_r787149579
##########
File path: r/R/dplyr-join.R
##########
@@ -117,10 +117,33 @@ handle_join_by <- function(by, x, y) {
if (is.null(names(by))) {
by <- set_names(by)
}
- # TODO: nicer messages?
- stopifnot(
- all(names(by) %in% names(x)),
- all(by %in% names(y))
- )
+
+ missing_x_cols <- setdiff(names(by), names(x))
+ if (length(missing_x_cols) > 0) {
+ message <- paste(
+ "Join",
+ ngettext(length(missing_x_cols), "column", "columns"),
+ "must be present in data."
+ )
+ message_x <- paste(
+ oxford_paste(missing_x_cols, quote_symbol = "`"),
+ "not present in x."
+ )
+ abort(c(message, x = message_x))
+ }
+
+ missing_y_cols <- setdiff(by, names(y))
+ if (length(missing_y_cols) > 0) {
+ message <- paste(
+ "Join",
+ ngettext(length(missing_y_cols), "column", "columns"),
+ "must be present in data."
+ )
+ message_y <- paste(
+ oxford_paste(missing_y_cols, quote_symbol = "`"),
+ "not present in y."
+ )
+ abort(c(message, x = message_y))
+ }
Review comment:
I had a similar thought and I have a hunch this might be the reason for
{dplyr} keeping things simpler / a bit more ambiguous. I will look into it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]