-
Notifications
You must be signed in to change notification settings - Fork 25.8k
SQL: MIN/MAX/AVG/SUM/PERCENTILE/PERCENTILE RANK handling on NULL values #34896
Copy link
Copy link
Closed
Labels
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.