Skip to content

[ES|QL] ResolveRefs may not resolve a resolvable aggregation with groupings completely and cause IllegalStateException #116781

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

Closed
fang-xing-esql opened this issue Nov 13, 2024 · 1 comment · Fixed by #127524
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@fang-xing-esql
Copy link
Member

This was discussed during reviewing #115814 , it is kind of an edge case, however it does expose some issues with resolving an aggregation with groupings. References are created for groupings in the aggregates, and if the items in groupings cannot be resolved the first time resolveAggregate is called, its reference is marked with customMessage = true, and it prevents further attempts to resolve this reference. We might need a way to allow further attempts to resolve the references created in aggregates.

from sample_data
| EVAL date = "2024-01-01"::datetime
| stats max = MAX(@timestamp) BY c = (date == "2024-01-01")

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_state_exception",
        "reason" : "Found 1 problem\nline 1:57: Plan [Aggregate[STANDARD,[c{r}#5],[MAX(@timestamp{f}#11,true[BOOLEAN]) AS max, ?c]]] optimized incorrectly due to missing references [?c]"
      }
    ],
    "type" : "illegal_state_exception",
    "reason" : "Found 1 problem\nline 1:57: Plan [Aggregate[STANDARD,[c{r}#5],[MAX(@timestamp{f}#11,true[BOOLEAN]) AS max, ?c]]] optimized incorrectly due to missing references [?c]"
  },
  "status" : 500
}
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Nov 13, 2024
@elasticsearchmachine
Copy link
Collaborator

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

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
2 participants