eitsupi commented on code in PR #13641:
URL: https://github.com/apache/arrow/pull/13641#discussion_r928066536


##########
r/R/dplyr.R:
##########
@@ -184,6 +184,29 @@ dim.arrow_dplyr_query <- function(x) {
   c(rows, cols)
 }
 
+#' @export
+unique.arrow_dplyr_query <- function(x, incomparables = FALSE, fromLast = 
FALSE, ...) {
+
+  if (incomparables == TRUE) {
+    arrow_not_supported("`unique()` with `incomparables = TRUE`")
+  }
+
+  if (fromLast == TRUE) {
+    arrow_not_supported("`unique()` with `fromLast = TRUE`")
+  }
+
+  x <- dplyr::distinct(x)
+  dplyr::collect(x)

Review Comment:
   Since dtplyr does not do collect, perhaps it would be more consistent to not 
do collect here as well.
   
https://github.com/tidyverse/dtplyr/blob/2181de14668fdad46f5068b56bd34e440b3b6749/R/step-call.R#L208-L214
   
   ``` r
   mtcars |> dtplyr::lazy_dt() |> unique()
   #> Source: local data table [32 x 11]
   #> Call:   unique(`_DT1`)
   #>
   #>     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
   #>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
   #> 1  21       6   160   110  3.9   2.62  16.5     0     1     4     4
   #> 2  21       6   160   110  3.9   2.88  17.0     0     1     4     4
   #> 3  22.8     4   108    93  3.85  2.32  18.6     1     1     4     1
   #> 4  21.4     6   258   110  3.08  3.22  19.4     1     0     3     1
   #> 5  18.7     8   360   175  3.15  3.44  17.0     0     0     3     2
   #> 6  18.1     6   225   105  2.76  3.46  20.2     1     0     3     1
   #> # … with 26 more rows
   #>
   #> # Use as.data.table()/as.data.frame()/as_tibble() to access results
   ```
   
   <sup>Created on 2022-07-23 by the [reprex 
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
   
   Because `unique` is not defined in dbplyr, it appears that `unique.default` 
is being called for `unique(arrow::to_duckdb())`
   



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