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

Inconsistent Null handling in array_max/min functions in presence of NaN #22716

Open
bikramSingh91 opened this issue May 10, 2024 · 2 comments
Open
Assignees
Labels

Comments

@bikramSingh91
Copy link
Contributor

bikramSingh91 commented May 10, 2024

presto returns a NaN, even if there is a NULL in the array. However, for other types, it always returns NULL if one exists. As a part of fixing the NaN behavior under this RFC (https://github.com/prestodb/rfcs/blob/main/RFC-0001-nan-definition.md), it would be good to also make the behavior consistent across types for nulls and always return null if it exists.

select ARRAY_MIN(array[1, 3, NULL , 3]);  ---- NULL
select ARRAY_MIN(array['a','b', NULL, 'c']);  ---- NULL
select ARRAY_MIN(array[1, nan(), NULL , 3]);  ---- nan

Similarly for array_max

select ARRAY_MAX(array['a','b', NULL, 'c']);  ---- NULL
select ARRAY_MAX(array[1, 3, NULL , 3]);  ---- NULL
select ARRAY_MAX(array[1, nan(), NULL , 3]);  ---- nan
@elharo elharo changed the title Inconsistent Null handling in array_max/min functions Inconsistent Null handling in array_max/min functions in presence of NaN May 16, 2024
@elharo
Copy link
Contributor

elharo commented May 16, 2024

NaN's a weird one. I'm not sure we should do this. I'm not sure we shouldn't. However, I do notice that the RFC doesn't address the case of null comparisons with NaN and whichever way we go it likely should.

@rschlussel
Copy link
Contributor

with the new plan, nan is treated like a regular number, so null comparisons with nan would like any other comparison with null (i.e. unknown).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🆕 Unprioritized
Development

No branches or pull requests

3 participants