-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add array_average Presto function #2434
Conversation
✅ Deploy Preview for meta-velox canceled.
|
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.
@jwyles-ahana Thank you for adding one more Presto function. Please, add documentation and look into CI failures.
d47cdcb
to
fa75cd1
Compare
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 for contributing this!
} | ||
|
||
template <typename TOutput, typename TInput> | ||
FOLLY_ALWAYS_INLINE void callNullFree(TOutput& out, const TInput& array) { |
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.
To be consistent with the implementation of "call" and the Presto documentation this should return null if the input array is empty, so the return type should be bool.
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.
Change made.
fa75cd1
to
ba8519d
Compare
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 for adding this function. Please add documentation in array.rst.
@@ -30,6 +30,11 @@ inline void registerArraySumFunction() { | |||
registerFunction<ArraySumFunction, OT, IT>({"array_sum_alt"}); | |||
} | |||
|
|||
template <typename OT, typename IT> |
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.
Nit: Since we don't bind this function for multiple types, the usage of template variables doesn't seem worthwhile to me.
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.
+1
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.
I have removed the registerArrayAverageFunction() method.
template <typename TOutput, typename TInput> | ||
FOLLY_ALWAYS_INLINE bool call(TOutput& out, const TInput& array) { | ||
TOutput sum = 0; | ||
int count = 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.
nit: int64_t or size_t?
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.
Changed to size_t
template <typename T> | ||
struct ArrayAverageFunction { | ||
VELOX_DEFINE_FUNCTION_TYPES(T) | ||
template <typename TOutput, typename TInput> |
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.
TOutput is always double.
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.
Rewrote call and callNullFree methods as non-templated.
2a604d5
to
0e029ef
Compare
@mbasmanova @laithsakka What else needs to be done for this PR? |
double& out, | ||
const arg_type<Array<double>>& array) { | ||
// If the array is empty then set result to null | ||
if (array.size() == 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.
add {
}
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.
looks good just one minor missing braces before i import it.
@laithsakka has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
@laithsakka has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
using limits = std::numeric_limits<double>; | ||
auto input = makeNullableArrayVector<double>( | ||
{{limits::infinity(), 1.0, 2.0}, | ||
{limits::min(), 1.0, 2.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.
@jwyles-ahana There is a linter warning. Would you double check?
Use of std::numeric_limits<T>::min() on floating-point type T.
Use std::numeric_limits<T>::lowest() instead ofstd::numeric_limits<T>::min() where T is a floating-point type.
std::numeric_limits<T>min() behaves counter-intuitively when T isa floating-point type (e.g. float, double, long double, etc.). Thismost likely does not do what the author intends.
Lint code: CLANGTIDY
Lint name: facebook-hte-FloatingPointMin
- {limits::min(), 1.0, 2.0},
+ {limits::lowest(), 1.0, 2.0},
@jwyles-ahana This PR is almost complete, but there is a linter warning. Any chance you could fix it so we could merge this PR? |
40b74b6
to
1cb0e54
Compare
1cb0e54
to
9dcb718
Compare
@mbasmanova @laithsakka I have made the requested changes and now all checks are passing except the conbench one. I am not sure how anything in this commit could affect any of the existing benchmarks... Any ideas on what to look for to fix this? |
@jwyles-ahana Thanks. conbench is known to be flaky. It is fine to ignore the failures. CC: @pedroerp @raulcd @kgpai @laithsakka Laith, would you re-import and land this PR? |
@jwyles-ahana @laithsakka Folks, anything blocking this PR? |
@jwyles-ahana Can you update with latest ? Should be good to merge/land after that . |
@aditi-pandit I can take over the function. Maybe we can close this PR and I will open a new one with the same changes (I cannot push directly to this fork). |
@isadikov : Yes, that is fine. We had contacted James, but didn't hear back. Please refernce this original PR in your new one. |
This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions! |
I am still working on this. |
This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions! |
Implementing array_average as a simple function.