Skip to content

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

@bikramSingh91

Description

@bikramSingh91

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions