Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST_CENTROID_AGG returns POINT(NaN NaN) on empty records #106025

Closed
craigtaverner opened this issue Mar 6, 2024 · 2 comments · Fixed by #114888
Closed

ST_CENTROID_AGG returns POINT(NaN NaN) on empty records #106025

craigtaverner opened this issue Mar 6, 2024 · 2 comments · Fixed by #114888
Assignees
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.0.0

Comments

@craigtaverner
Copy link
Contributor

craigtaverner commented Mar 6, 2024

Elasticsearch Version

8.14

Installed Plugins

No response

Java Version

bundled

OS Version

all

Problem Description

If we aggregate over zero records, we get POINT (NaN NaN). I think the default behaviour in ES|QL is to return null instead of NaN, and in this case a null centroid, not null coordinates.

For example:

FROM airports
| WHERE ST_INTERSECTS(location, city_location)
| STATS centroid=ST_CENTROID_AGG(location), count=COUNT()

Returns:

centroid:geo_point  |  count:long
POINT (NaN NaN)     |  0

But should return:

centroid:geo_point  |  count:long
null                |  0

And a warning.

Steps to Reproduce

Create an index with two geo_point fields, but do not add any documents.

Query with:

FROM index | STATS centroid=ST_CENTROID_AGG(location, other_location), count=COUNT(*)

Logs (if relevant)

No response

@craigtaverner craigtaverner added >bug needs:triage Requires assignment of a team area label :Analytics/Geo Indexing, search aggregations of geo points and shapes Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.14.0 and removed needs:triage Requires assignment of a team area label labels Mar 6, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@craigtaverner craigtaverner self-assigned this Mar 14, 2024
@craigtaverner craigtaverner changed the title ST_CENTROID returns POINT(NaN NaN) on empty records ST_CENTROID_AGG returns POINT(NaN NaN) on empty records May 2, 2024
@bpintea
Copy link
Contributor

bpintea commented May 7, 2024

Related: #98698.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Geo Indexing, search aggregations of geo points and shapes >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants