Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Skip validating remote cluster index names in parser #114271

Merged
merged 26 commits into from
Oct 16, 2024

Conversation

fang-xing-esql
Copy link
Member

@fang-xing-esql fang-xing-esql commented Oct 8, 2024

Resolves: #114201

Skip the validation of index names in parser if it is from a remote cluster.

Reduce the scope of #112081 to local indices only.

It is mainly because the behavior of invalid indices names on remote cluster is inconsistent with local cluster, for example these commands below pass even though the index name is invalid or remote cluster does not exists.

FROM *:invalid#index
FROM *fake:invalid#index

It is better to defer the validation of remote cluster indices names to later phase or until the pattern is clear.

@elasticsearchmachine
Copy link
Collaborator

Hi @fang-xing-esql, I've created a changelog YAML for you.

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 8, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/kibana-esql (ES|QL-ui)

@bpintea
Copy link
Contributor

bpintea commented Oct 10, 2024

Resolves: #114201

Not sure if that needs resolving: the grammar allows FROM with unquoted_index | quoted_index | unquoted_remote_cluster:(unquoted_index | quoted_index). So if smth is quoted only, that has to be an index.

@bpintea
Copy link
Contributor

bpintea commented Oct 10, 2024

It is better to defer the validation of remote cluster indices names to later phase

But will it not eventually fail anyways? In my understanding the point was to not allow later phases to execute, if we know it's for nothing.
However, if the failure is drastically different and we want to keep consistency, that could be a reason to skip the validation, but is that the case?

@astefan
Copy link
Contributor

astefan commented Oct 10, 2024

It is better to defer the validation of remote cluster indices names to later phase

But will it not eventually fail anyways? In my understanding the point was to not allow later phases to execute, if we know it's for nothing. However, if the failure is drastically different and we want to keep consistency, that could be a reason to skip the validation, but is that the case?

The story is more complex than this :-). I am in favor of skipping the validation of anything related to CCS. See this discussion for more context. Depending on skip_available setting we might or might not fail a query to a remote cluster.

Copy link
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

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

Lgtm

for (String command : List.of("FROM", "METRICS")) {
List<String> commands = new ArrayList<>();
commands.add("FROM");
if (Build.current().isSnapshot()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the tests run in non-snapshot code? Can stay as is, was just wondering.

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't have the assumeTrue for snapshot, just be to cautious.

@@ -71,6 +75,9 @@ private static void validateIndexPattern(String indexPattern, EsqlBaseParser.Ind
String[] indices = indexPattern.split(",");
boolean hasExclusion = false;
for (String index : indices) {
if (isRemoteIndexName(index)) { // skip the validation if there is remote cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is a bit baffling unless you dig in the grammar to understand that when quoting an index pattern, this can actually contain a remote index pattern, which is accepted downstream. I guess a comment (somewhere) would be nice to the next reader, but can also be merged as is without it.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM - please backport this to 8.16 also.

@fang-xing-esql fang-xing-esql added v8.16.0 auto-backport Automatically create backport pull requests when merged labels Oct 16, 2024
@fang-xing-esql fang-xing-esql merged commit 64ae0ae into elastic:main Oct 16, 2024
16 checks passed
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

The backport operation could not be completed due to the following error:

An unexpected error occurred when attempting to backport this PR.

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 114271

@fang-xing-esql
Copy link
Member Author

💚 All backports created successfully

Status Branch Result
8.x
8.16

Questions ?

Please refer to the Backport tool documentation

fang-xing-esql added a commit to fang-xing-esql/Elasticsearch that referenced this pull request Oct 16, 2024
…#114271)

* skip validating remote cluster index names in parser

(cherry picked from commit 64ae0ae)
elasticsearchmachine pushed a commit that referenced this pull request Oct 16, 2024
#114960)

* skip validating remote cluster index names in parser

(cherry picked from commit 64ae0ae)
elasticsearchmachine pushed a commit that referenced this pull request Oct 16, 2024
#114959)

* skip validating remote cluster index names in parser

(cherry picked from commit 64ae0ae)
georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Oct 25, 2024
…#114271)

* skip validating remote cluster index names in parser
@fang-xing-esql fang-xing-esql deleted the validate-index-name branch October 30, 2024 02:51
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Nov 4, 2024
…#114271)

* skip validating remote cluster index names in parser
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 ES|QL-ui Impacts ES|QL UI Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.16.0 v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ES|QL] CCS index with quotes fails
6 participants