-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r_base::sum()
handling na.rm =
#75
Conversation
r_base::sum()
passthroughr_base::sum()
handling na.rm =
unique_ptr<FunctionData> BindRSum(ClientContext &context, AggregateFunction &function, vector<unique_ptr<Expression>> &arguments) { | ||
function = SumFun::GetFunctions().GetFunctionByArguments(context, {arguments[0]->return_type}); | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: handle arguments[1]
here, i.e. if it is TRUE
go through the data and if we find a null, then bind to a function that returns a null somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can assume a constant here, duckplyr won't let anything else through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
unique_ptr<FunctionData> BindRSum(ClientContext &context, AggregateFunction &function, vector<unique_ptr<Expression>> &arguments) { | ||
function = SumFun::GetFunctions().GetFunctionByArguments(context, {arguments[0]->return_type}); | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can assume a constant here, duckplyr won't let anything else through.
handling library(duckdbrfuns)
rfuns_sum(1:10)
#> [1] 55
rfuns_sum(c(1:10, NA))
#> [1] 55
rfuns_sum(c(1:10, NA), na.rm = TRUE)
#> [1] 55
rfuns_sum(c(1:10, NA), na.rm = FALSE)
#> [1] NA
rfuns_sum(integer(), na.rm = FALSE)
#> [1] 0
rfuns_sum(integer(), na.rm = TRUE)
#> [1] 0
rfuns_sum(NA_integer_, na.rm = TRUE)
#> [1] 0
rfuns_sum(NA_integer_, na.rm = FALSE)
#> [1] NA Created on 2024-04-24 with reprex v2.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We also want sum(logical())
, but this could be a separate PR.
closes #70