Skip to content

Conversation

@alex-spies
Copy link
Contributor

@alex-spies alex-spies commented Apr 3, 2025

Backport

This will backport the following commits from 8.18 to 8.x:

(Forward-porting the already merged 8.18 backport rather than backporting the main commit from #125764 as the former already has resolved conflicts.)

…lastic#126166)

* Revert changes to Layout.java

The change in 80125a4 is a quick fix
and allows breaking an invariant of Layout. Revert that.

* Simplify ReplaceMissingFieldWithNull

When encountering projections, it tries to do the job of field
extraction for missing fields by injecting an Eval that creates a
literal null with the same name id as the field attribute for the
missing field. This is wrong:
1. We only insert an Eval in case that a Project relies on the missing
   attribute. There could be other plan nodes that rely on the missing
   attribute.
2. Even for Projects, we only insert an Eval in case we squarely project
   for the field - in case of aliases (e.g. from RENAME), we do nothing.
3. In case of multiple Projects that use this attribute, we create
   multiple attributes with the original field attribute's id, causing
   a wrong Layout. This triggered
   elastic#121754.

* Revive logic for EsRelation instead of Project

* Update LocalLogicalPlanOptimizerTests

* Update test expectations

* Do not prune attributes from EsRelation

This can lead to empty output, which leads to the EsRelation being
replaced by a LocalRelation with 0 rows.

* Add tests + capability

* Add comments

* [CI] Auto commit changes from spotless

* Update docs/changelog/125764.yaml

---------

Co-authored-by: elasticsearchmachine <[email protected]>
(cherry picked from commit 96ca13a)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
@alex-spies alex-spies changed the title [8.x] [8.18] ESQL: ESQL: Fix ReplaceMissingFieldsWithNull (#125764) (#126166) [8.x] ESQL: ESQL: Fix ReplaceMissingFieldsWithNull (#125764) Apr 3, 2025
@alex-spies alex-spies added >bug auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Analytics/ES|QL AKA ESQL labels Apr 3, 2025
@elasticsearchmachine elasticsearchmachine merged commit 5157a7f into elastic:8.x Apr 3, 2025
15 checks passed
@alex-spies alex-spies deleted the backport/8.x/pr-126166 branch April 3, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >bug v8.19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants