Skip to content
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

Closed

Conversation

jwyles-ahana
Copy link
Contributor

Implementing array_average as a simple function.

@netlify
Copy link

netlify bot commented Aug 31, 2022

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 9dcb718
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/634db7b39b586900080937f6

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2022
Copy link
Contributor

@mbasmanova mbasmanova left a 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.

Copy link
Contributor

@kevinwilfong kevinwilfong left a 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change made.

Copy link
Collaborator

@aditi-pandit aditi-pandit left a 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>
Copy link
Collaborator

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOutput is always double.

Copy link
Contributor Author

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.

@jwyles-ahana jwyles-ahana force-pushed the array_average branch 5 times, most recently from 2a604d5 to 0e029ef Compare September 12, 2022 21:56
@jwyles-ahana
Copy link
Contributor Author

@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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add {
}

Copy link
Contributor

@laithsakka laithsakka left a 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.

@facebook-github-bot
Copy link
Contributor

@laithsakka has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@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},
Copy link
Contributor

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

@mbasmanova
Copy link
Contributor

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

@jwyles-ahana jwyles-ahana force-pushed the array_average branch 3 times, most recently from 40b74b6 to 1cb0e54 Compare October 17, 2022 20:12
@jwyles-ahana
Copy link
Contributor Author

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

@mbasmanova
Copy link
Contributor

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

@mbasmanova
Copy link
Contributor

@jwyles-ahana @laithsakka Folks, anything blocking this PR?

@kgpai
Copy link
Contributor

kgpai commented Jan 3, 2023

@jwyles-ahana Can you update with latest ? Should be good to merge/land after that .

@isadikov
Copy link
Contributor

@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).

@aditi-pandit
Copy link
Collaborator

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

facebook-github-bot pushed a commit that referenced this pull request Jan 24, 2023
Summary:
Based on #2434.

Pull Request resolved: #3741

Reviewed By: pedroerp

Differential Revision: D42705940

Pulled By: mbasmanova

fbshipit-source-id: 22105ec895fb93a30dc4c0b3d54b0afeff418240
@stale
Copy link

stale bot commented Apr 18, 2023

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!

@stale stale bot added the stale label Apr 18, 2023
@isadikov
Copy link
Contributor

I am still working on this.

@stale stale bot removed the stale label Apr 18, 2023
@stale
Copy link

stale bot commented Jul 17, 2023

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!

@stale stale bot added the stale label Jul 17, 2023
@stale stale bot closed this Jul 31, 2023
marin-ma pushed a commit to marin-ma/velox-oap that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants