Skip to content

PPL stats command throws NullPointerException on empty index #4

@qianheng-aws

Description

@qianheng-aws

Description

Running a PPL stats command on an empty index causes a NullPointerException instead of returning an empty result set.

Steps to reproduce

  1. Create an empty index: PUT /empty_test
  2. Run PPL: source=empty_test | stats count()
  3. Get a 500 error with NullPointerException in the logs

Stack trace

java.lang.NullPointerException
    at org.opensearch.sql.expression.aggregation.CountAggregator.iterate(CountAggregator.java:45)
    at org.opensearch.sql.planner.physical.AggregationOperator.next(AggregationOperator.java:78)

Expected behavior

Should return count() = 0 for an empty index.

Environment

  • OpenSearch 2.17
  • 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