Skip to content

ESQL: make unmapped_fields="load" automatically trigger for partially mapped KEYWORD fields, and allow projecting partially mapped non-KEYWORD fields#144228

Merged
alex-spies merged 88 commits intoelastic:mainfrom
alex-spies:fix-non-loaded-partially-mapped-fields
Apr 14, 2026
Merged

ESQL: make unmapped_fields="load" automatically trigger for partially mapped KEYWORD fields, and allow projecting partially mapped non-KEYWORD fields#144228
alex-spies merged 88 commits intoelastic:mainfrom
alex-spies:fix-non-loaded-partially-mapped-fields

Conversation

@alex-spies
Copy link
Copy Markdown
Contributor

@alex-spies alex-spies commented Mar 13, 2026

Fix #141994, fix #145206

AI-assisted PR

TODO:

  • Find another approach that preserves the validation "must not touch PUNKs outside of KEEP/DROP".
  • Find all PUNKs and PUKs in ResolveTable, not inside ResolveRefs.
  • In UnionTypesCleanup, turn PUNKs back into simple field attributes so we load values for them in the fields that do have mappings, but fill with nulls for indices where they are unmapped.
  • Because we cannot piggyback on the union type verification anymore, put in a separate verification that disallows PUNKs except in KEEP/DROP; we can re-use the one removed in 98bb0fb because it was duplicating the union type verification and had no effect.
  • Move respective tests to unmapped-type-conflicts.csv-spec rather than unmapped-load.csv-spec
  • Potentially remove ResolveRefs#resolvePartiallyMapped and ResolveRefs#propagateInsistedFields if they continue being unused.
  • Add tests to x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/192_unmapped_load_partial_non_keyword.yml resp. add expected values. replaced by spec tests
  • Probably also fix ESQL: unmapped_fields="load" optimized incorrectly for partially unmapped non-KEYWORD fields #145206 in the process
  • Also add tests with union types: they should continue to be passed through as null columns.
  • Check if we have date/nanos spec tests already, this should pass if there's an explicit convert.

@alex-spies alex-spies changed the title ESQL: unmapped_fields="load" should automatically trigger for all partially mapped fields ESQL: unmapped_fields="load" should automatically trigger for partially mapped KEYWORD fields Mar 25, 2026
@alex-spies alex-spies marked this pull request as ready for review March 25, 2026 17:48
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 25, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@astefan astefan self-requested a review March 26, 2026 08:49
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @alex-spies, I've created a changelog YAML for you.

@alex-spies
Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, @astefan and @mouhc1ne !

@alex-spies alex-spies enabled auto-merge (squash) April 13, 2026 06:53
Copy link
Copy Markdown
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


SET unmapped_fields="load"\;
FROM employees, employees_no_names METADATA _index
| KEEP emp_no, first_name, last_name, _index
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why you also keep the last_name here, but I don't have an argument good enough to NOT keep it.

@alex-spies alex-spies merged commit 9e8fb9f into elastic:main Apr 14, 2026
35 checks passed
alex-spies added a commit to alex-spies/elasticsearch that referenced this pull request Apr 14, 2026
… mapped fields (elastic#144228)

* Unconditionally load partially mapped keyword fields, whether they are mentioned in expressions or not. Also, always load values of partially mapped fields from the indices where they are mapped.
* Fix "optimized incorrectly" for `KEEP foo` with partially mapped fields.
* Move detection of PUNKs/PUKs to ResolveTable.
* Add temporary manual validation against usage of PUNKs in expressions to keep current behavior.
* Add ability to unmap fields to CsvTestsDataLoader.

---------

Co-authored-by: Mouhcine Aitounejjar <5037925+mouhc1ne@users.noreply.github.com>
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
9.4

@alex-spies alex-spies deleted the fix-non-loaded-partially-mapped-fields branch April 14, 2026 17:05
elasticsearchmachine pushed a commit that referenced this pull request Apr 15, 2026
… mapped fields (#144228) (#146262)

* Unconditionally load partially mapped keyword fields, whether they are mentioned in expressions or not. Also, always load values of partially mapped fields from the indices where they are mapped.
* Fix "optimized incorrectly" for `KEEP foo` with partially mapped fields.
* Move detection of PUNKs/PUKs to ResolveTable.
* Add temporary manual validation against usage of PUNKs in expressions to keep current behavior.
* Add ability to unmap fields to CsvTestsDataLoader.

---------

Co-authored-by: Mouhcine Aitounejjar <5037925+mouhc1ne@users.noreply.github.com>
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-backport Automatically create backport pull requests when merged >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.4.0 v9.5.0

Projects

None yet

6 participants