[ 
https://issues.apache.org/jira/browse/ARROW-14712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17443655#comment-17443655
 ] 

Romain Francois commented on ARROW-14712:
-----------------------------------------

In this part of the compare_dplyr_error() function: 

 

{{msg <- tryCatch(}}
{{    rlang::eval_tidy(expr, rlang::new_data_mask(rlang::env(.input = tbl))),}}
{{    error = function(e) {}}
{{      msg <- conditionMessage(e)}}{{      # The error here is of the form:}}
{{      #}}
{{      # Problem with `filter()` .input `..1`.}}
{{      # x object 'b_var' not found}}
{{      # ℹ Input `..1` is `chr == b_var`.}}
{{      #}}
{{      # but what we really care about is the `x` block}}
{{      # so (temporarily) let's pull those blocks out when we find them}}
{{      pattern <- i18ize_error_messages()}}{{      if (grepl(pattern, msg)) {}}
{{        msg <- sub(paste0("^.*(", pattern, ").*$"), "\\1", msg)}}
{{      }}}
{{      msg}}
{{    }}}
{{  )}}

 

{{we can with the next dplyr pick up the parent condition instead, i.e. msg <- 
conditionMessage(e$parent). This should work for this one, but not sure it 
works generally. }}

> [R] compare_dplyr_error() too strict
> ------------------------------------
>
>                 Key: ARROW-14712
>                 URL: https://issues.apache.org/jira/browse/ARROW-14712
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Romain Francois
>            Priority: Major
>
> dplyr errors are about to be updated and so the mechanism used by 
> compare_dplyr_error() fails:
> I'm seeing this on the revdeps :
> {{══ Failed tests 
> ════════════════════════════════════════════════════════════════}}
> {{── Error (test-dplyr-filter.R:263:3): filter environment scope 
> ─────────────────}}
> {{Error in `lapply(args, function(x) {}}
> {{{}if (!inherits(x, "Expression")){}}}{{{}{ x <- Expression$scalar(x) 
> }{}}}{{{}x{}}}
> {{})`: object 'b_var' not found}}
> {{Backtrace:}}
> {{▆}}
> {{1. ├─arrow:::expect_dplyr_error(input %>% filter(chr == b_var), tbl) at 
> test-dplyr-filter.R:263:2}}
> {{2. │ ├─testthat::expect_error(...) at 
> tests/testthat/helper-expectation.R:158:2}}
> {{3. │ │ └─testthat:::expect_condition_matching(...)}}
> {{4. │ │ └─testthat:::quasi_capture(...)}}
> {{5. │ │ ├─testthat .capture(...)}}
> {{6. │ │ │ └─base::withCallingHandlers(...)}}
> {{7. │ │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))}}
> {{8. │ └─rlang::eval_tidy(expr, rlang::new_data_mask(rlang::env(input = 
> record_batch(tbl))))}}
> {{9. ├─input %>% filter(chr == b_var)}}
> {{10. ├─dplyr::filter(., chr == b_var)}}
> {{11. └─arrow:::filter.ArrowTabular(., chr == b_var)}}
> {{12. └─base::lapply(filts, arrow_eval, arrow_mask(.data))}}
> {{13. └─arrow FUN(X[[i]], ...)}}
> {{14. └─base::tryCatch(...)}}
> {{15. └─base tryCatchList(expr, classes, parentenv, handlers)}}
> {{16. └─base tryCatchOne(expr, names, parentenv, handlers[[1L]])}}
> {{{}17. └─value[[3L]](cond){}}}{{{}[ FAIL 1 | WARN 3 | SKIP 58 | PASS 5783 
> ]{}}}
> {{Error: Test failures}}
> {{{}Execution halted{}}}{{{}1 error x | 0 warnings ✓ | 1 note x{}}}
>  
> here's a reprex showing what's happening: 
> {{``` r}}
> {{library(dplyr, warn.conflicts = FALSE)}}
> {{{}library(arrow, warn.conflicts = FALSE){}}}{{{}E <- function(expr) \{ 
> tryCatch(expr, error = function(cnd) print(cnd, backtrace = 
> FALSE))}{}}}{{{}tbl <- tibble::tibble({}}}
> {{  chr = letters[c(1:5, NA, 7:10)]}}
> {{{}){}}}{{{}E({}}}
> {{  tbl %>% }}
> {{    filter(chr == b_var)}}
> {{)}}
> {{#> <error/rlang_error>}}
> {{#> Error in `filter()`:}}
> {{#>   Problem while computing `..1 = chr == b_var`.}}
> {{#> Caused by error:}}
> {{#>   object 'b_var' not found}}
> {{E(}}
> {{  record_batch(tbl) %>% }}
> {{    filter(chr == b_var)}}
> {{)}}
> {{#> <simpleError in lapply(args, function(x) \{    if (!inherits(x, 
> "Expression")) {        x <- Expression$scalar(x)    }    x}): object 'b_var' 
> not found>}}
> {{{}```{}}}{{{}<sup>Created on 2021-11-15 by the [reprex 
> package](https://reprex.tidyverse.org) (v2.0.1.9000)</sup>{}}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to