The attached file will create a table and run 2 queries, the first of which is not honoring the requested sort order. I expect the Nulls first.
I have found this problem in Postgres 12.7 (pop os) and 14.6 (mac Postgres.app)
Incorrect:
select "last_name", "first_name", count("actor_id")
from actor
where (( "actor_id" >= 1 ) and ( "last_name" = 'GUINESS' ) and ( "first_name" = 'PENELOPE' ))
group by rollup( 1, 2 )
order by 1 asc nulls first, 2 asc nulls first;
last_name | first_name | count
-----------+------------+-------
GUINESS | PENELOPE | 1
GUINESS | | 1
| | 1
Expected:
select "last_name", "first_name", count("actor_id")
from actor
where (( "actor_id" >= 1 ) and ( "last_name" = 'GUINESS' ))
group by rollup( 1, 2 )
order by 1 asc nulls first, 2 asc nulls first;
last_name | first_name | count
-----------+------------+-------
| | 1
GUINESS | | 1
GUINESS | PENELOPE | 1
(3 rows)
The only difference between the two queries is the "first_name" filter added to the second.
Thank you!
Chris