Skip to content

[BUG] percentile returns wrong value in V2 #3495

Closed
@xinyual

Description

@xinyual

What is the bug?
When we use percentile aggregation but no input, it will return 0 instead of null.

How can one reproduce the bug?
Create a index with two items

POST /demo/_doc
{
    "demo1": 1,
    "demo2": 1
}
POST /demo/_doc
{
    "demo1": null,
    "demo2": null
}

Then call calcite

POST /_plugins/_ppl/
{
    "query": "source=demo | stats percentile(demo1, 50) by demo2"
}

It returns

{
    "schema": [
        {
            "name": "percentile(demo1, 50)",
            "type": "long"
        },
        {
            "name": "demo2",
            "type": "long"
        }
    ],
    "datarows": [
        [
            0,
            null
        ],
        [
            1,
            1
        ]
    ],
    "total": 2,
    "size": 2
}

Here we return 0 for the bin when demo2 is null. But actually no any input here. So we should return null. 0 has quantitative meanings .

What is the expected behavior?
Return null

What is your host/environment?

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions