ESQL: Fix projection generation when pruning left join#135446
ESQL: Fix projection generation when pruning left join#135446bpintea merged 6 commits intoelastic:mainfrom
Conversation
Currently, in case (locally) the join key is null, the whole join is replaced with an Eval and a Project. The project however contain only reference attributes. This is insufficient, in case the attribute should point to another attribute pointing to a literal null added in the Eval. This fixes that by allowing the generated Project to contain NamedExpressions, which can then be proper Aliases.
|
Hi @bpintea, I've created a changelog YAML for you. |
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
astefan
left a comment
There was a problem hiding this comment.
LGTM
For someone like me (who takes a PR for a spin with a sample query and dissects its internals and results) I would like to also see a concrete query in csv-spec file. You shared one with me offline and I think it wouldn't hurt to also have that one bundled in the PR, as well.
from languages_lookup_non_unique_key | eval language_code = null::integer | lookup join languages_lookup_non_unique_key on language_code
|
Actually... (sorry about that), I had an idea for a test and it turns out we don't have a test for that and with this PR it has a wrong behavior: Before this PR, the result is: with this PR, the order of the columns changes (and it's wrong): |
Indeed, due to the updated method overriding, the |
There was a problem hiding this comment.
These changes make insure that the country field is part of the languages_lookup_non_unique_key schema. Otherwise the CSV tests generate an index resolution without it, which leads to failed queries when using the index in FROM.
The index was previously using similar languages schema, which lacks the fields, but which was added in dynamically by the data. Also, the index had only been used in LOOKUP JOIN before.
The change then also leads to updated order of the MV value ["Germany", "Austria"]
|
Thanks, Andrei! |
💔 Backport failed
You can use sqren/backport to manually backport by running |
Currently, in case the join key is (locally) null, the whole join is replaced with an `Eval` and a `Project`. The project however contain only reference attributes. This is insufficient, in case the attribute should point to another attribute pointing to a literal `null` added in the `Eval`. This fixes that by allowing the generated `Project` to contain `NamedExpression`s, which can then be proper `Alias`es. This is done by adjusting the join output calculation to work with the `NamedExpression`s, instead of just `Attribute`s.
…6078) Currently, in case the join key is (locally) null, the whole join is replaced with an `Eval` and a `Project`. The project however contain only reference attributes. This is insufficient, in case the attribute should point to another attribute pointing to a literal `null` added in the `Eval`. This fixes that by allowing the generated `Project` to contain `NamedExpression`s, which can then be proper `Alias`es. This is done by adjusting the join output calculation to work with the `NamedExpression`s, instead of just `Attribute`s.
Currently, in case the join key is (locally) null, the whole join is replaced with an
Evaland aProject. The project however contain only reference attributes. This is insufficient, in case the attribute should point to another attribute pointing to a literalnulladded in theEval.This fixes that by allowing the generated
Projectto containNamedExpressions, which can then be properAliases.This is done by adjusting the join output calculation to work with the
NamedExpressions, instead of justAttributes.