paleolimbot commented on issue #15055:
URL: https://github.com/apache/arrow/issues/15055#issuecomment-1362810236

   Maybe `n_distinct()` instead of `count_distinct()`?
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   library(dplyr, warn.conflicts = FALSE)
   
   # doesn't work in dplyr either
   mtcars |> 
     as_arrow_table() |> 
     summarise(count_distinct(mpg)) |> 
     collect()
   #> Warning: Error in summarize_eval(names(exprs)[i], exprs[[i]], ctx, 
length(.data$group_by_vars) >  : 
   #>   Expression count_distinct(mpg) is not an aggregate expression or is not 
supported in Arrow; pulling data into R
   #> Error:
   #> ! Problem while computing `..1 = count_distinct(mpg)`.
   #> Caused by error in `count_distinct()`:
   #> ! could not find function "count_distinct"
   
   #> Backtrace:
   #>      ▆
   #>   1. ├─dplyr (local) `<fn>`(.data = `<df[,1]>`, count_distinct(mpg))
   #>   2. ├─dplyr:::summarise.data.frame(.data = `<df[,1]>`, 
count_distinct(mpg))
   #>   3. │ └─dplyr:::summarise_cols(.data, dplyr_quosures(...), caller_env = 
caller_env())
   #>   4. │   ├─base::withCallingHandlers(...)
   #>   5. │   └─dplyr:::map(quosures, summarise_eval_one, mask = mask)
   #>   6. │     └─base::lapply(.x, .f, ...)
   #>   7. │       └─dplyr (local) FUN(X[[i]], ...)
   #>   8. │         └─mask$eval_all_summarise(quo)
   #>   9. └─base::.handleSimpleError(...)
   #>  10.   └─dplyr (local) h(simpleError(msg, call))
   #>  11.     └─rlang::abort(bullets, call = error_call, parent = 
skip_internal_condition(e))
   
   # maybe this one?
   mtcars |> 
     as_arrow_table() |> 
     summarise(n_distinct(mpg)) |> 
     collect()
   #> # A tibble: 1 × 1
   #>   `n_distinct(mpg)`
   #>               <int>
   #> 1                25
   ```
   
   <sup>Created on 2022-12-22 with [reprex 
v2.0.2](https://reprex.tidyverse.org)</sup>


-- 
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]

Reply via email to