-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Support enrich ANY mode in cross clusters query #104840
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
Conversation
909753d
to
bbf39a7
Compare
bbf39a7
to
8bbedbf
Compare
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
Hi @dnhatn, I've created a changelog YAML for you. |
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java
Show resolved
Hide resolved
.../src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Show resolved
Hide resolved
Pinging @elastic/es-analytical-engine (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Left some minor comments.
...ugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java
Show resolved
Hide resolved
.../src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java
Show resolved
Hide resolved
.../src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClustersEnrichIT.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
...plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolverTests.java
Show resolved
Hide resolved
@astefan Thanks for the detailed review. It's ready again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Left few very small comments.
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichPolicyResolver.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments from my side - thanks for the large suite of tests!
@@ -148,7 +148,7 @@ public void testNonExistentEnrichPolicy() throws IOException { | |||
); | |||
assertThat( | |||
EntityUtils.toString(re.getResponse().getEntity()), | |||
containsString("unresolved enrich policy [countris], did you mean [countries]?") | |||
containsString("enrich policy [countris] doesn't exist, did you mean [countries]?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there might a security setting (thus the policy can exist but not be visible) might be better to have the "cannot find enrich policy [countries], did you mean [...]).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can happen in the future, but the current security model is all or nothing for enrich policies. I will look into it later, as I am working on the coordinator mode based on this PR.
@Before | ||
public void setupHostsEnrich() { | ||
// the hosts policy are identical on every node | ||
Map<String, String> allHosts = Map.of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there's value in externalizing the content to a .properties
file and which can simply read afterwards.
@@ -23,11 +23,11 @@ public static class PreAnalysis { | |||
public static final PreAnalysis EMPTY = new PreAnalysis(emptyList(), emptyList()); | |||
|
|||
public final List<TableInfo> indices; | |||
public final List<String> policyNames; | |||
public final List<Enrich> unresolvedEnriches; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything is unresolved in the preAnalyzer - I suggest using policies
or enrichPolicies
instead or enriches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++, I have renamed this to enriches
in 11d4d7e
if (PlannerUtils.hasUnsupportedEnrich(physicalPlan)) { | ||
listener.onFailure(new IllegalArgumentException("Enrich modes COORDINATOR and REMOTE are not supported yet")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better handled in the Verifier - no need to hold the PR for it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be removed shortly.
Note to reviewers: I apologize for the size of this PR, but I have tried to minimize its scope. You can skip most of the changes except for the EnrichPolicyResolver class, which contains the main changes.
This PR enables the resolution of enrich policies from multiple clusters, involving the following steps:
I considered alternative approaches, but this approach requires at most one cross-cluster call for each cluster.
With this capability, the ENRICH mode ANY now works across clusters. I have enabled enrich in MultiClusterSpecIT and added small IT tests. Additional tests will be added in subsequent PRs.
I plan to have several follow-ups to fully support enrich in cross-cluster queries.