-
Notifications
You must be signed in to change notification settings - Fork 19
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: improve error message when getting an invalid .data #339
base: main
Are you sure you want to change the base?
Conversation
@@ -33,7 +33,10 @@ as_duckplyr_df <- function(.data) { | |||
} | |||
|
|||
if (!identical(class(.data), "data.frame") && !identical(class(.data), c("tbl_df", "tbl", "data.frame"))) { | |||
cli::cli_abort("Must pass a plain data frame or a tibble to `as_duckplyr_df()`.") | |||
cli::cli_abort(c( | |||
"Must pass a plain data frame or a tibble to `as_duckplyr_df()`, not {.obj_type_friendly { .data}}.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the space before .data
is compulsory, I got this error from cli:
Error in "fun(..., .envir = .envir)" :
! Invalid cli literal: `{.data}` starts with a dot.
ℹ Interpreted literals must not start with a dot in cli >= 3.4.0.
ℹ `{}` expressions starting with a dot are now only used for cli styles.
ℹ To avoid this error, put a space character after the starting `{` or use parentheses: `{(.data)}`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should then be a comment, and/or a test.
This is how benchmark results would change (along with a 95% confidence interval in relative change) if cf2b613 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm just envisioning someone removing that seemingly extra space in a future revision.
@@ -33,7 +33,10 @@ as_duckplyr_df <- function(.data) { | |||
} | |||
|
|||
if (!identical(class(.data), "data.frame") && !identical(class(.data), c("tbl_df", "tbl", "data.frame"))) { | |||
cli::cli_abort("Must pass a plain data frame or a tibble to `as_duckplyr_df()`.") | |||
cli::cli_abort(c( | |||
"Must pass a plain data frame or a tibble to `as_duckplyr_df()`, not {.obj_type_friendly { .data}}.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should then be a comment, and/or a test.
|
||
by_cyl <- dplyr::group_by(mtcars, cyl) | ||
expect_snapshot(error = TRUE, { | ||
as_duckplyr_df(by_cyl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe in this case the error is misleading, would you convert a grouped data.frame by converting it thus losing its grouping
This is how benchmark results would change (along with a 95% confidence interval in relative change) if e718a07 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
Fix #127
Not docs but this was a low-hanging fruit to warm up. 😉