Skip to content

SQL: Inconsistent default ordering of NULL values with and without GROUP BY #77068

@Luegg

Description

@Luegg

The default null ordering strategy is differs depending on wether a GROUP BY clause is present or not:

select languages l from test_emp where salary > 73000 order by l

       l
---------------
1
2
3
4
null
null
select languages l from test_emp where salary > 73000 group by l order by l

       l
---------------
null
1
2
3
4

For DESC order, the same issue occurs but in reversed direction.

The desired behavior would probably be to have consistent null ordering for ASC and DESC respectively. The SQL standard does not prescribe a default null ordering if NULLS FIRST/LAST is not specified and various databases implement it differently. E.g. H2 treats null as the smallest value and Postgres treats it as the largest value if not specified otherwise.

This issue is related to #34550 which asks for the support of explicit null ordering with NULLS FIRST/LAST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Analytics/SQLSQL querying>bugTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions