Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/min-nan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #10052 Result of min/max aggregate functions in columnar aggregation pipeline possibly inconsistent with plain Postgres result
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static pg_attribute_always_inline void
FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value)
{
FUNCTION_NAME(state) *state = (FUNCTION_NAME(state) *) agg_state;
if (!state->isvalid || PREDICATE(DATUM_TO_CTYPE(state->value), value) || isnan((double) value))
if (!state->isvalid || PREDICATE(DATUM_TO_CTYPE(state->value), value))
{
/*
* Note that float8 Datum is by-reference on 32-bit systems, and this
Expand Down
9 changes: 9 additions & 0 deletions tsl/test/expected/vector_agg_functions.out
Original file line number Diff line number Diff line change
Expand Up @@ -7158,4 +7158,13 @@ select ss, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1;
11 | 1 | 65
12 | 1 | 65

-- NaN handling in Postgres minmax is different from other functions -- it treats
-- NaN as bigger than any number. This test has a filter that ensures that
-- NaNs go first in the source data, because some potentially buggy conditions
-- can be only triggered in this case.
select ss, min(cfloat4), max(cfloat4) from aggfns where cfloat4 = any(array['nan'::float4, 33.308792]) group by ss order by ss;
ss | min | max
----+---------+-----
11 | 33.3088 | NaN

reset max_parallel_workers_per_gather;
6 changes: 6 additions & 0 deletions tsl/test/sql/vector_agg_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,10 @@ select ss, count(*), min(f1) from edges where f1 = 63 group by 1 order by 1;
select ss, count(*), min(f1) from edges where f1 = 64 group by 1 order by 1;
select ss, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1;

-- NaN handling in Postgres minmax is different from other functions -- it treats
-- NaN as bigger than any number. This test has a filter that ensures that
-- NaNs go first in the source data, because some potentially buggy conditions
-- can be only triggered in this case.
select ss, min(cfloat4), max(cfloat4) from aggfns where cfloat4 = any(array['nan'::float4, 33.308792]) group by ss order by ss;

reset max_parallel_workers_per_gather;
Loading