Description
Running a PPL stats command on an empty index causes a NullPointerException instead of returning an empty result set.
Steps to reproduce
- Create an empty index:
PUT /empty_test
- Run PPL:
source=empty_test | stats count()
- 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
Description
Running a PPL
statscommand on an empty index causes a NullPointerException instead of returning an empty result set.Steps to reproduce
PUT /empty_testsource=empty_test | stats count()Stack trace
Expected behavior
Should return
count() = 0for an empty index.Environment