Skip to content

ES|QL: Fix column references for FORK #127209

Closed
@ioanatia

Description

@ioanatia

related #121950
The constant folding does not work correctly for FORK.
This is one symptom of how we carry and reuse the column references in FORK from the FORK sub plans.

Take this example:

FROM search-movies METADATA _id
| FORK ( EVAL a = 1 | WHERE _id == "1" )
       ( EVAL a = 2 | WHERE _id == "2" )
| KEEP _id, _fork, a
| WHERE a == 1

This should only return the results of the first FORK branch, but it ends up returning both.
The reason for this is because when constant folding is done at the level of the logical plan optimizer the condition | WHERE a == 1 becomes WHERE true. The reference for the a column is the one from the first FORK branch.

We should fix the output of FORK, such that we don't reuse the same columns references from the FORK branches.
I assume STATS does something similar, but I haven't checked yet.

Metadata

Metadata

Assignees

Labels

:Search Relevance/SearchCatch all for Search Relevance>bugTeam:Search RelevanceMeta label for the Search Relevance team in Elasticsearchpriority:highA label for assessing bug priority to be used by ES engineersv9.1.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions