paleolimbot commented on a change in pull request #11904:
URL: https://github.com/apache/arrow/pull/11904#discussion_r765330660



##########
File path: r/R/dplyr-funcs.R
##########
@@ -0,0 +1,128 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+#' @include expression.R
+NULL
+
+
+#' Register compute translations
+#'
+#' The `register_translation()` and `register_translation_agg()` functions
+#' are used to populate a list of functions that operate on (and return)
+#' Expressions. These are the basis for the `.data` mask inside dplyr methods.
+#'
+#' @section Writing translations:
+#' When to use `build_expr()` vs. `Expression$create()`?
+#'
+#' Use `build_expr()` if you need to
+#' - map R function names to Arrow C++ functions
+#' - wrap R inputs (vectors) as Array/Scalar
+#'
+#' `Expression$create()` is lower level. Most of the translations use it
+#' because they manage the preparation of the user-provided inputs
+#' and don't need or don't want to the automatic conversion of R objects
+#' to [Scalar].
+#'
+#' @param fun_name A function name in the form `"function"` or
+#'   `"package::function"`. The package name is currently not used but
+#'   may be used in the future to allow these types of function calls.
+#' @param fun A function or `NULL` to un-register a previous function.
+#'   This function must accept `Expression` objects as arguments and return
+#'   `Expression` objects instead of regular R objects.
+#' @param agg_fun An aggregate function or `NULL` to un-register a previous
+#'   aggregate function. This function must accept `Expression` objects as
+#'   arguments and return a `list()` with components:
+#'   - `fun`: string function name
+#'   - `data`: `Expression` (these are all currently a single field)
+#'   - `options`: list of function options, as passed to call_function
+#' @param registry An `environment()` in which the functions should be
+#'   assigned.
+#'
+#' @return The previously registered function or `NULL` if no previously
+#'   registered function existed.
+#' @keywords internal
+#'
+register_translation <- function(fun_name, fun, registry = 
translation_registry()) {
+  name <- gsub("^.*?::", "", fun_name)
+  namespace <- gsub("::.*$", "", fun_name)

Review comment:
       I added this one:
   
   
https://github.com/apache/arrow/blob/76b4301371a18abaad91f189807f59218b75b90e/r/tests/testthat/test-dplyr-funcs.R#L29-L30
   
   but maybe there's more there that isn't tested?




-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to