Skip to content

Fix queries with missing index, skip_unavailable and filters#130344

Merged
smalyshev merged 2 commits intoelastic:mainfrom
smalyshev:fix-skip-un-filter
Jun 30, 2025
Merged

Fix queries with missing index, skip_unavailable and filters#130344
smalyshev merged 2 commits intoelastic:mainfrom
smalyshev:fix-skip-un-filter

Conversation

@smalyshev
Copy link
Contributor

@smalyshev smalyshev commented Jun 30, 2025

Fix filtered query not being handled correctly when remote indices are missing and skip_unavailable=true. In this case, we need to produce exception on the first pass and have the second pass sort it out - whether it's legit index being filtered, or missing index.

@smalyshev smalyshev added :Analytics/ES|QL AKA ESQL >bug v9.2.0 auto-backport Automatically create backport pull requests when merged v9.1.0 v8.19.0 labels Jun 30, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @smalyshev, I've created a changelog YAML for you.

@smalyshev smalyshev marked this pull request as ready for review June 30, 2025 18:39
@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch labels Jun 30, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@smalyshev smalyshev requested review from astefan, dnhatn and quux00 June 30, 2025 18:41
@smalyshev smalyshev added auto-backport Automatically create backport pull requests when merged and removed auto-backport Automatically create backport pull requests when merged labels Jun 30, 2025
@smalyshev smalyshev requested a review from Copilot June 30, 2025 19:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the handling of filtered queries when remote indices are missing and skip_unavailable is true by adjusting error propagation and cluster state marking. Key changes include:

  • Updating the error condition in EsqlCCSUtils.java to account for a non-null filter.
  • Modifying test scenarios in CrossClusterQueryWithFiltersIT.java to reflect remote index changes and new error messages.
  • Updating the changelog documentation to summarize the bug fix.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java Adjusted the condition to include a filter flag for error handling.
x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterQueryWithFiltersIT.java Updated test scenarios to check for remote index failures and error messages.
docs/changelog/130344.yaml Added changelog entry for the bug fix.
Comments suppressed due to low confidence (1)

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java:224

  • Consider enhancing the inline comment to clarify why a non-null filter leads to bypassing the final state marking, ensuring the intended behavior is clearly understood by future maintainers.
                if (executionInfo.isSkipUnavailable(c) == false || filter != null) {
Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM

@smalyshev smalyshev merged commit 3b13977 into elastic:main Jun 30, 2025
32 checks passed
smalyshev added a commit to smalyshev/elasticsearch that referenced this pull request Jun 30, 2025
…#130344)

* Fix queries with missing index, skip_unavailable and filters
smalyshev added a commit to smalyshev/elasticsearch that referenced this pull request Jun 30, 2025
…#130344)

* Fix queries with missing index, skip_unavailable and filters
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.19
9.1
elasticsearchmachine pushed a commit that referenced this pull request Jul 1, 2025
#130370)

* Fix queries with missing index, skip_unavailable and filters
elasticsearchmachine pushed a commit that referenced this pull request Jul 1, 2025
#130369)

* Fix queries with missing index, skip_unavailable and filters
@smalyshev smalyshev deleted the fix-skip-un-filter branch July 1, 2025 16:30
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 3, 2025
…#130344)

* Fix queries with missing index, skip_unavailable and filters
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 :Search Foundations/CCS Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v8.19.0 v9.1.0 v9.2.0

4 participants