Skip to content

ESQL: Fix unresolved name pattern#143210

Merged
elasticsearchmachine merged 10 commits intoelastic:mainfrom
alex-spies:fix-unresolved-name-pattern
Mar 2, 2026
Merged

ESQL: Fix unresolved name pattern#143210
elasticsearchmachine merged 10 commits intoelastic:mainfrom
alex-spies:fix-unresolved-name-pattern

Conversation

@alex-spies
Copy link
Copy Markdown
Contributor

Thanks @ebarlas for the find!

Supersedes #143191.

  • Fix UnresolvedNamePatternTests by actually ensuring that the equality is sensitive to changes of the name.
  • Fix UnresolvedNamePattern#equals and #hashCode to account for differences in the name

We probably never saw problems from this in production because the name is derived from the pattern. Basic equality methods should still work correctly, however.

@alex-spies alex-spies added >bug auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v9.4.0 v9.3.2 labels Feb 27, 2026
@alex-spies alex-spies requested a review from astefan February 27, 2026 08:42
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Feb 27, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

case 1 -> pattern = randomValueOtherThan(pattern, () -> randomAlphaOfLength(4));
}
return new UnresolvedNamePattern(source, null, name, pattern);
return new UnresolvedNamePattern(source, null, pattern, name);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was switched up as discovered by @ebarlas . This made is that in very much most of cases, the mutation changed the pattern, anyway, and thus we never saw that changes to the name had no effect on equality.

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 with a small nit about a comment. Thank you @alex-spies

private final CharacterRunAutomaton automaton;
private final String pattern;
// string representation without backquotes
// cannot just use NamedExpression.name() because the superclass gives this a constant value of "<unresolved>"
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 was looking at this comment and I realized the class hierarchy is confusing.

  • NamedExpression has a private field name and a public name() method
  • UnresolvedNamedExpression overrides name() to throw UnresolvedException
  • UnresolvedNamePattern has a different name private field and overrides name() to return this name.

So the comment here is about the name() in UnresolvedNamePattern I believe which doesn't return <unresolved> but throws an exception. I think a better comment here would be

Cannot rely on NamedExpression.name: the UnresolvedNamedExpression superclass throws on name()
and stores "<unresolved>" as the internal name field.

But the class hierarchy still remains confusing. Not something for this PR though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Your comment is better.

I'll also go and rename the private member name to actualName just so it is a tiny bit less confusing.

@elasticsearchmachine elasticsearchmachine merged commit c065bf4 into elastic:main Mar 2, 2026
35 checks passed
@alex-spies alex-spies deleted the fix-unresolved-name-pattern branch March 2, 2026 11:16
alex-spies added a commit to alex-spies/elasticsearch that referenced this pull request Mar 2, 2026
Thanks @ebarlas for the find!

Supersedes elastic#143191.

* Fix `UnresolvedNamePatternTests` by actually ensuring that the equality is sensitive to changes of the `name`.
* Fix `UnresolvedNamePattern#equals` and `#hashCode` to account for differences in the `name`

We probably never saw problems from this in production because the name
is derived from the pattern. Basic equality methods should still work
correctly, however.
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
9.3

elasticsearchmachine pushed a commit that referenced this pull request Mar 2, 2026
Thanks @ebarlas for the find!

Supersedes #143191.

* Fix `UnresolvedNamePatternTests` by actually ensuring that the equality is sensitive to changes of the `name`.
* Fix `UnresolvedNamePattern#equals` and `#hashCode` to account for differences in the `name`

We probably never saw problems from this in production because the name
is derived from the pattern. Basic equality methods should still work
correctly, however.
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 2, 2026
…cations

* upstream/main: (60 commits)
  Use batches for other bulk vector benchmarks (elastic#143167)
  Mute org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT test {csv-spec:lookup-join.MvJoinKeyOnTheLookupIndexAfterStats} elastic#143388
  Mute org.elasticsearch.snapshots.ConcurrentSnapshotsIT testBackToBackQueuedDeletes elastic#143387
  [Inference API] Parse endpoint metadata from persisted endpoints (elastic#143081)
  Add cluster formation doc to DistributedArchitectureGuide (elastic#143318)
  Fix flattened root block loader null expectation (elastic#143238)
  Unmute ValueSourceReaderTypeConversionTests testLoadAll (elastic#143189)
  ESQL: Add split coalescing for many small files (elastic#143335)
  Unmute mixed-cluster spatial parse warning test (elastic#143186)
  Fix zero-size estimate in BytesRefBlock null test (elastic#143258)
  Make DataType and DataFormat top-level enums (elastic#143312)
  Add support for steps to change the target index name for later steps (elastic#142955)
  Set mayContainDuplicates flag to test deduplication (elastic#143375)
  ESQL: Fix Driver search load millis as nanos bug (elastic#143267)
  Mute org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT test {csv-spec:lookup-join.LookupJoinWithMixPushableAndUnpushableFilters} elastic#143378
  ESQL: Forbid MV_EXPAND before full text functions (elastic#143249)
  ESQL: Fix unresolved name pattern (elastic#143210)
  Implement boxplot queryDSL aggregation for exponential_histograms (elastic#143026)
  Add prefetching to x64 bulk vector implementations (elastic#142387)
  Make large segment vector tests resilient to memory constraints (elastic#143366)
  ...
tballison pushed a commit to tballison/elasticsearch that referenced this pull request Mar 3, 2026
Thanks @ebarlas for the find!

Supersedes elastic#143191.

* Fix `UnresolvedNamePatternTests` by actually ensuring that the equality is sensitive to changes of the `name`.
* Fix `UnresolvedNamePattern#equals` and `#hashCode` to account for differences in the `name`

We probably never saw problems from this in production because the name
is derived from the pattern. Basic equality methods should still work
correctly, however.
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 auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.2 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants