Skip to content

SQL: MIN/MAX/AVG/SUM/PERCENTILE/PERCENTILE RANK handling on NULL values #34896

@astefan

Description

@astefan
sql> select max(languages) max, min(languages) min, sum(languages) sum, percentile(languages, 80) percent, percentile_rank(languages, 3) percent_rank, avg(languages) avg from test_emp group by languages;
      max      |      min      |      sum      |    percent    | percent_rank  |      avg
---------------+---------------+---------------+---------------+---------------+---------------
-Infinity      |Infinity       |0.0            |NaN            |NaN            |NaN
1.0            |1.0            |15.0           |1.0            |100.0          |1.0
2.0            |2.0            |38.0           |2.0            |100.0          |2.0
3.0            |3.0            |51.0           |3.0            |100.0          |3.0
4.0            |4.0            |72.0           |4.0            |0.0            |4.0
5.0            |5.0            |105.0          |5.0            |0.0            |5.0

The first line is for null values in the languages field. Shouldn't MIN and MAX of null values return a null? Same question for SUM. Not so sure about PERCENTILE and PERCENTILE_RANK though... ES returns null for these two. If MIN and MAX would return null probably the same should be done for AVG.
Opening this one up for discussion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions