ianmcook commented on a change in pull request #11018:
URL: https://github.com/apache/arrow/pull/11018#discussion_r711111279



##########
File path: r/R/dplyr-summarize.R
##########
@@ -136,6 +136,17 @@ summarize_eval <- function(name, quosure, ctx, recurse = 
FALSE) {
     return()
   }
 
+  if ("median" %in% funs_in_expr) {
+    expr <- wrap_median(expr)

Review comment:
       @nealrichardson this implementation will not actually work until #11159 
is merged and we have a `list_element` scalar kernel, but the gist of this as 
follows:
   
   We need to translate `median(x, na.rm)` to `list_element(tdigest(x, q = 0.5, 
skip_nulls = na.rm), 0)` but because of how aggregate function bindings work, 
it isn't possible to do that directly in the definition for `agg_funcs$median`, 
so I hacked together this solution in which `summarize_eval()` calls a function 
named `wrap_median()` that recurses through the expression AST and replaces 
`median(...)` with `arrow_list_element(median(...))`.
   
   Can you think of a more straightforward immediate solution to this?
   
   I think we should ask for a `median()` kernel to avoid having to do all 
these contortions in the R bindings.




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