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
}