paleolimbot commented on code in PR #13397:
URL: https://github.com/apache/arrow/pull/13397#discussion_r915967027
##########
r/R/query-engine.R:
##########
@@ -190,7 +190,7 @@ ExecPlan <- R6Class("ExecPlan",
}
node
},
- Run = function(node) {
+ Run = function(node, as_table = FALSE) {
Review Comment:
With the improvements to `SafeCallIntoR()` the failure mode a *little*
better (at least mentions user-defined function).
``` r
library(arrow, warn.conflicts = FALSE)
#> Some features are not enabled in this build of Arrow. Run `arrow_info()`
for more information.
library(dplyr, warn.conflicts = FALSE)
fun <- arrow_scalar_function(
function(x) x + 1,
int32(), int64()
)
register_user_defined_function(fun, "plus_one")
record_batch(a = 2L) |>
mutate(b = plus_one(a)) |>
to_duckdb() |>
collect()
#> Error in duckdb_execute(res): duckdb_execute_R: Failed to run query
#> Error: Invalid Input Error: arrow_scan: get_next failed():
NotImplemented: Call to R (resolve scalar user-defined function output data
type) from a non-R thread from an unsupported context
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/kernel.cc:391
resolver_(ctx, args)
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec.cc:696
kernel_->signature->out_type().Resolve(kernel_ctx_, args.inputs)
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec/expression.cc:602
executor->Init(&kernel_context, {kernel, descrs, options})
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec/project_node.cc:92
ExecuteScalarExpression(simplified_expr, target, plan()->exec_context())
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/dataset/scanner.cc:79
delegate_.Next()
#>
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/c/bridge.cc:1651
reader()->ReadNext(&batch)
```
I could attempt something more automatic in this PR (like `read_table()` or
`write_dataset()`) when this error occurs in `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]