jonkeane commented on a change in pull request #11032:
URL: https://github.com/apache/arrow/pull/11032#discussion_r723267014



##########
File path: r/R/duckdb.R
##########
@@ -118,3 +118,38 @@ duckdb_disconnector <- function(con, tbl_name) {
   })
   environment()
 }
+
+#' Create an Arrow object from others
+#'
+#' This can be used in pipelines that pass data back and forth between Arrow 
and
+#' other processes (like DuckDB).
+#'
+#' @param .data the object to be converted
+#' @param as_table should the results be materialized as a table? (default: 
TRUE)
+#'
+#' @return an `arrow_dplyr_query` object, to be used in dplyr pipelines.
+#' @export
+#'
+#' @examplesIf getFromNamespace("run_duckdb_examples", "arrow")()
+#' library(dplyr)
+#'
+#' ds <- InMemoryDataset$create(mtcars)
+#'
+#' ds %>%
+#'   filter(mpg < 30) %>%
+#'   to_duckdb() %>%
+#'   group_by(cyl) %>%
+#'   summarize(mean_mpg = mean(mpg, na.rm = TRUE)) %>%
+#'   to_arrow() %>%
+#'   collect()
+to_arrow <- function(.data, as_table = TRUE) {

Review comment:
       Ultimately, I don't believe we want to have `as_table = TRUE`, but I've 
added it _for now_ to show that 
`arrow_dplyr_query(duckdb::duckdb_fetch_record_batch(res)$read_table())` (the 
default, `as_table = TRUE`)  works just fine, but when we 
`arrow_dplyr_query(duckdb::duckdb_fetch_record_batch(res))` we get a segfault. 
   
   We might need (or want) to release with the `$read_table()` version this 
time, and then upgrade to the version that doesn't convert to a table in 7.0.0 
(after duckdb resolves the issue + releases, presuming the issue is on their 
side)




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