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

ESQL: AUTO_BUCKET() can return NaN #105166

Closed
bpintea opened this issue Feb 5, 2024 · 2 comments · Fixed by #110380
Closed

ESQL: AUTO_BUCKET() can return NaN #105166

bpintea opened this issue Feb 5, 2024 · 2 comments · Fixed by #110380
Assignees
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@bpintea
Copy link
Contributor

bpintea commented Feb 5, 2024

Description

Specifying a zero as the number of buckets with numeric field will return NaN instead of null (due to div by 0).
Ex: ROW AUTO_BUCKET(1, 0, 0, 0)

Same for negative number of buckets (due to log10(negative)).
Ex: ROW AUTO_BUCKET(1, -1, 0, 0)

Same for a number of buckets value that wraps over int (due to int overflow).
Ex: ROW AUTO_BUCKET(0, 100000000000, 0, 0)

Related: #98698.

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Feb 5, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@bpintea bpintea changed the title ESQL: AUTO_BUCKET(numeric, 0, ..., ...) returns NaN ESQL: AUTO_BUCKET() can return NaN Feb 5, 2024
@luigidellaquila luigidellaquila self-assigned this Jul 2, 2024
@luigidellaquila
Copy link
Contributor

This issue does not seem to reproduce anymore.
AUTO_BUCKET function was renamed as BUCKET and is now only allowed as a grouping function, so the queries above return a validation exception.

The following queries return NULL as expected.

ROW a = 1 | stats max(a) by BUCKET(1, 0, 0, 0)
ROW a = 1 | stats max(a) by BUCKET(1, -1, 0, 0)
ROW a = 1 | stats max(a) by BUCKET(0, 100000000000, 0, 0)

Internally, some parts of the code still produce a NaN, but downstream it is resolved to NULL.

I'll add some tests, then I think this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants