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

DROP of EVAL planning issues #107083

Closed
dnhatn opened this issue Apr 4, 2024 · 2 comments · Fixed by #107131 or #107328
Closed

DROP of EVAL planning issues #107083

dnhatn opened this issue Apr 4, 2024 · 2 comments · Fixed by #107131 or #107328
Assignees
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@dnhatn
Copy link
Member

dnhatn commented Apr 4, 2024

PUT /test/_doc/1?refresh
{
    "k": "a",
    "v": 1
}
PUT /test/_doc/2?refresh
{
    "k": "a",
    "v": 2
}
POST /_query?error_trace
{
    "query": "FROM test | EVAL k1 = k | STATS avg(v) BY k, k1 | DROP k1"
}
"reason": "Found 1 problem\nline 1:27: Plan [Aggregate[[k{f}#199, k1{r}#192],[SUM(v{f}#198) AS $$SUM$avg(v)$0, COUNT(v{f}#198) AS $$COUNT$avg(v)$1, k{f}#199]]] optimized incorrectly due to missing references [k1{r}#192]",

And without aggs

POST /_query?error_trace
{
    "query": "FROM test | EVAL k1 = k | STATS BY k, k1 | DROP k1"
}
"stack_trace": "java.lang.NullPointerException: Cannot invoke \"org.elasticsearch.xpack.esql.planner.Layout$ChannelSet.nameIds()\" because the return value of 
 \"java.util.List.get(int)\" is null
\tat org.elasticsearch.xpack.esql.planner.ExchangeLayout.get(ExchangeLayout.java:36)
\tat org.elasticsearch.xpack.esql.planner.AbstractPhysicalOperationProviders.groupingPhysicalOperation(AbstractPhysicalOperationProviders.java:122)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planAggregation(LocalExecutionPlanner.java:234)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:182)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planProject(LocalExecutionPlanner.java:508)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:196)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planLimit(LocalExecutionPlanner.java:548)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:200)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.planOutput(LocalExecutionPlanner.java:267)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:224)
\tat org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:167)
\tat org.elasticsearch.xpack.esql.plugin.ComputeService.runCompute(ComputeService.java:441)
\tat org.elasticsearch.xpack.esql.plugin.ComputeService.execute(
        ComputeService.java:208)
\tat org.elasticsearch.xpack.esql.plugin.TransportEsqlQueryAction.lambda$innerExecute$4(TransportEsqlQueryAction.java:166)
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Apr 4, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@alex-spies alex-spies self-assigned this Apr 4, 2024
costin added a commit to costin/elasticsearch that referenced this issue Apr 5, 2024
Recursive aliases (eval x = 1, x1 = x) were not taken into account when
 combining projections causing the target field to be lost (and only the
 immediate intermediate named expression to be used instead which became
 invalid).

Fix elastic#107083
@costin costin assigned costin and unassigned alex-spies Apr 5, 2024
costin added a commit that referenced this issue Apr 5, 2024
Recursive aliases (eval x = 1, x1 = x) were not taken into account when
 combining projections causing the target field to be lost (and only the
 immediate intermediate named expression to be used instead which became
 invalid).

Fix #107083
costin added a commit to costin/elasticsearch that referenced this issue Apr 5, 2024
Recursive aliases (eval x = 1, x1 = x) were not taken into account when
 combining projections causing the target field to be lost (and only the
 immediate intermediate named expression to be used instead which became
 invalid).

Fix elastic#107083

(cherry picked from commit a9388e1)
elasticsearchmachine pushed a commit that referenced this issue Apr 5, 2024
Recursive aliases (eval x = 1, x1 = x) were not taken into account when
 combining projections causing the target field to be lost (and only the
 immediate intermediate named expression to be used instead which became
 invalid).

Fix #107083

(cherry picked from commit a9388e1)
@alex-spies
Copy link
Contributor

Re-opening as I found another reproducer:

FROM employees
| EVAL k = languages, k1 = k
| STATS c = 3*COUNT() BY languages, k, k1, languages
| DROP k
Found 1 problem
line 3:3: Plan [Aggregate[[languages{f}#101, k{r}#95],[COUNT([2a][KEYWORD]) AS $$COUNT$3*count(*)$0, languages{f}#101]]] optimized incorrectly due to missing references [k{r}#95]

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