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

Handle Nan in ArrayMinMax function and remove a todo. #6922

Closed

Conversation

amitkdutta
Copy link
Contributor

Differential Revision: D49935894

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 4ced2ff
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/652071042b94e000087eca5f

@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 Oct 5, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

@amitkdutta amitkdutta requested a review from laithsakka October 5, 2023 21:45
amitkdutta pushed a commit to amitkdutta/velox that referenced this pull request Oct 6, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

@amitkdutta amitkdutta changed the title Remove a todo in ArrayMinMaxFunction. Handle Nan in ArrayMinMax function and remove a todo. Oct 6, 2023
@zacw7
Copy link
Contributor

zacw7 commented Oct 6, 2023

Thanks for the quick fix. Could you please double check if other similar functions also have the same issue such as sum(), avg()?

amitkdutta pushed a commit to amitkdutta/velox that referenced this pull request Oct 6, 2023
Summary:
Also, re-use input strings for result.


Differential Revision: D49935894
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

amitkdutta pushed a commit to amitkdutta/velox that referenced this pull request Oct 6, 2023
Summary:
Also, re-use input strings for result.


Differential Revision: D49935894
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

amitkdutta pushed a commit to amitkdutta/velox that referenced this pull request Oct 6, 2023
Summary:
Also, re-use input strings for result.


Differential Revision: D49935894
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

@amitkdutta
Copy link
Contributor Author

Thanks for the quick fix. Could you please double check if other similar functions also have the same issue such as sum(), avg()?

Will look after this one.

amitkdutta pushed a commit to amitkdutta/velox that referenced this pull request Oct 6, 2023
Summary:
Also, re-use input strings for result.


Differential Revision: D49935894
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894

Summary: Pull Request resolved: facebookincubator#6922

Differential Revision: D49935894
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49935894


.. function:: array_min(array(E)) -> E

Returns the minimum value of input array. ::
Returns minimum non-NULL element of the array. Returns NULL if array is empty or contains a NULL element.
When E is DOUBLE or REAL, NaN value is considered greater than any non-NaN value. ::
Copy link
Contributor

Choose a reason for hiding this comment

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

Returns NULL if array is empty or contains a NULL element.
NaN value is considered greater than any non-NaN value.

This doesn't seem to hold true completely.
NaN seems to always be returned in both min_by and max_by even if NULL exists which also means its simultaneously considered both highest and lowest value.
Tried these on presto java:

SELECT array_max(ARRAY [nan(), 1.0]); => NaN 
SELECT array_max(ARRAY [NULL, nan(), 1.0]); => NaN 

SELECT array_min(ARRAY [nan(), 1.0]); => NaN 
SELECT array_min(ARRAY [NULL, nan(), 1.0]); => NaN 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch @bikramSingh91. In Presto, in presence of a NAN, the result is always NAN regardless of the other elements in the array for both min/max functions.

@amitkdutta amitkdutta closed this Nov 2, 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. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants