rdavis120 commented on issue #35604:
URL: https://github.com/apache/arrow/issues/35604#issuecomment-1553215854
Ok thanks, I think this works.
The reason to convert the columns to a struct was that since a udf can
support up to three argument, we can get around this by converting a table with
>3 columns to a struct, and then passing the struct as an argument to the udf,
which is before the collect().
library(arrow)
#
arrow::register_scalar_function(
"sum2",
function(context, x) {
rowSums(x, na.rm = T)
},
in_type = schema(x = struct(Sepal.Length = float64(), Sepal.Width =
float64(), Petal.Length = float64(), Petal.Width = float64())),
out_type = float64(),
auto_convert = T
)
#
arrow::write_dataset(iris, path = "iris.parquet")
x <- arrow::open_dataset("iris.parquet")
x |>
dplyr::mutate(x = data.frame(Sepal.Length, Sepal.Width, Petal.Length,
Petal.Width), .keep = "none") |>
dplyr::mutate(sum2 = sum2(x), .keep = "none") |>
dplyr::collect()
--
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]