thisisnic commented on issue #35431:
URL: https://github.com/apache/arrow/issues/35431#issuecomment-1534913273

   Thanks for reporting this @gongcastro! Once you call `to_duckdb()`, this 
converts the object to a virtual DuckDB table, so the error you're having 
likely doesn't reside within the Arrow codebase, so you might be best opening 
up an issue on [the DuckDB repo](https://github.com/duckdb/duckdb/issues).
   
   I've pasted a reprex below which shows this error being recreated using just 
duckdb without arrow:
   
   ``` r
   library(duckdb)
   library(dplyr)
   
   # with dplyr
   mtcars %>%
     group_by(am) |>
     mutate(seq_counts = 1:n()) |>
     collect()
   #> # A tibble: 32 × 12
   #> # Groups:   am [2]
   #>      mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb 
seq_counts
   #>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>      
<int>
   #>  1  21       6  160    110  3.9   2.62  16.5     0     1     4     4      
    1
   #>  2  21       6  160    110  3.9   2.88  17.0     0     1     4     4      
    2
   #>  3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1      
    3
   #>  4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1      
    1
   #>  5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2      
    2
   #>  6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1      
    3
   #>  7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4      
    4
   #>  8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2      
    5
   #>  9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2      
    6
   #> 10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4      
    7
   #> # ℹ 22 more rows
   
   # with DuckDB
   con <- dbConnect(duckdb::duckdb(), dbdir = ":memory:")
   duckdb::duckdb_register(con, "mtcars", mtcars)
   
   tbl(con, "mtcars") |>
     group_by(am) |>
     mutate(seq_counts = 1:n()) |>
     collect()
   #> Warning in 1:n(): NAs introduced by coercion
   #> Error in `purrr::pmap()`:
   #> ℹ In index: 2.
   #> Caused by error in `from:to`:
   #> ! NA/NaN argument
   #> Backtrace:
   #>      ▆
   #>   1. ├─dplyr::collect(mutate(group_by(tbl(con, "mtcars"), am), seq_counts 
= 1:n()))
   #>   2. ├─dbplyr:::collect.tbl_sql(...)
   #>   3. │ ├─dbplyr::db_sql_render(x$src$con, x, cte = cte)
   #>   4. │ └─dbplyr:::db_sql_render.DBIConnection(x$src$con, x, cte = cte)
   #>   5. │   ├─dbplyr::sql_render(sql, con = con, ..., cte = cte)
   #>   6. │   └─dbplyr:::sql_render.tbl_lazy(sql, con = con, ..., cte = cte)
   #>   7. │     ├─dbplyr::sql_render(...)
   #>   8. │     └─dbplyr:::sql_render.lazy_query(...)
   #>   9. │       ├─dbplyr::sql_build(query, con = con, ...)
   #>  10. │       └─dbplyr:::sql_build.lazy_select_query(query, con = con, ...)
   #>  11. │         └─dbplyr:::get_select_sql(...)
   #>  12. │           └─dbplyr:::translate_select_sql(con, select)
   #>  13. │             └─purrr::pmap(...)
   #>  14. │               └─purrr:::pmap_("list", .l, .f, ..., .progress = 
.progress)
   #>  15. │                 ├─purrr:::with_indexed_errors(...)
   #>  16. │                 │ └─base::withCallingHandlers(...)
   #>  17. │                 └─dbplyr (local) .f(...)
   #>  18. │                   └─dbplyr::translate_sql_(...)
   #>  19. │                     └─base::lapply(...)
   #>  20. │                       └─dbplyr (local) FUN(X[[i]], ...)
   #>  21. │                         ├─dbplyr::escape(eval_tidy(x, mask), con = 
con)
   #>  22. │                         └─rlang::eval_tidy(x, mask)
   #>  23. ├─1:n()
   #>  24. └─base::.handleSimpleError(`<fn>`, "NA/NaN argument", 
base::quote(from:to))
   #>  25.   └─purrr (local) h(simpleError(msg, call))
   #>  26.     └─cli::cli_abort(c(i = "In index: {i}."), parent = cnd, call = 
error_call)
   #>  27.       └─rlang::abort(...)
   ```


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