Skip to content

APPROX_PERCENTILE_CONT doesn't handle nulls and gives incorrect answer #11720

@Dandandan

Description

@Dandandan

Describe the bug

select APPROX_PERCENTILE_CONT(v, 0.5) FROM (VALUES (1), (2), (3), (NULL), (NULL), (NULL)) as t (v);
+------------------------------------------+
| APPROX_PERCENTILE_CONT(t.v,Float64(0.5)) |
+------------------------------------------+
| 0                                        |
+------------------------------------------+
1 row in set. Query took 0.002 seconds.

To Reproduce

No response

Expected behavior

Should return 2 (answer without nulls). 0 is not input, so obviously incorrect, ignoring the nulls it should have given NULL

Following PostgreSQL query also gives 2:

SELECT percentile_cont(0.5) WITHIN GROUP(order by v) FROM (VALUES (1), (2), (3), (NULL), (NULL), (NULL)) as t (v);

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions