-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Labels
Description
Current Behavior
Currently in Presto NaN() seems to behave like its > infinity,
select ARRAY_SORT(a) from (values array[NAN(), INFINITY(), -INFINITY(), 1]) as T(a);
— [ "-Infinity", 1, "Infinity", "NaN" ]
select ARRAY_SORT_Desc(a) from (values array[NAN(), INFINITY(), -INFINITY(), 1]) as T(a);
— ["NaN", "Infinity", 1, "-Infinity"]
This is not just limited to array_sort and you can see this behavior in order by too:
SELECT x, y from (values (1, 1.0), (2, NAN()), (3, -NAN()), (4, INFINITY()), (5, -INFINITY())) as T(x, y) order by y;
—
5 -Infinity
1 1
4 Infinity
2 NaN
3 NaN
However running
SELECT NAN() > INFINITY()
-- False
gives a contradictory answer.
Expected Behavior
Comparison with NaN is not defined so we should confirm to https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN.
Context
Velox is trying to ensure correctness with Presto Java but we are seeing inconsistencies in behavior and wanted clarifications on these.
tdcmeehan
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
✅ Done