Skip to content

PPL stats aggregation fails with NPE when index has zero documents #9

Description

@qianheng-aws

Bug

When running any PPL stats aggregation on an index with no documents, the query fails with a NullPointerException instead of returning an empty or zero result.

Reproduce

PUT /test_empty_index
source=test_empty_index | stats sum(amount), count()

Error response 500:

Caused by: java.lang.NullPointerException
  at org.opensearch.sql.expression.aggregation.CountAggregator.iterate(...)

Expected

Should return sum(amount) = null, count() = 0 gracefully.

Version

OpenSearch 2.17 with SQL plugin 2.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions