apache / apache/arrow

[R] please write unregister_scalar_function and/or make registration local/temporary

Open
#44,306 5 comments 0 reactions 0 assignees View on GitHub
Component: R Status: needs champion Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the enhancement requested

The current mechanism for `register_scalar_function` is solely by side-effect, and keeping them around in the global environment can affect other uses of lazy operations.

I suspect that its "global" side-effect use is fine for most, since a lazy object can be realized/collected at any point, and the registered function must exist when collected. I suggest that this risk can be mitigated with the assumption that de-registration must be after collection.

This might be as simple as what I hope would happen with the following, without the error:

```r
register_scalar_function("arrow_dirname", function(context, z) dirname(z), in_type=string(), out_type=string())

environment(register_scalar_function)$.cache$functions$arrow_dirname
# function (...)
# Expression$create("arrow_dirname", ...)
#

environment(register_scalar_function)$.cache$functions$arrow_dirname <- NULL
# Error in loadNamespace(x) : there is no package called ‘*tmp*’
```

### Component(s)

R

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.