-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Disallow CCS with lookup join #120277
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
Disallow CCS with lookup join #120277
Changes from 1 commit
1b99a4d
b8cf1b3
b1a0280
5f55608
57a0df6
c9b077e
c6be044
6a94eaf
d283968
66dd33c
343d104
416a8fc
a6aa610
59b78b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import org.elasticsearch.compute.data.Block; | ||
| import org.elasticsearch.index.IndexMode; | ||
| import org.elasticsearch.logging.Logger; | ||
| import org.elasticsearch.transport.RemoteClusterAware; | ||
| import org.elasticsearch.xpack.core.enrich.EnrichPolicy; | ||
| import org.elasticsearch.xpack.esql.Column; | ||
| import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException; | ||
|
|
@@ -653,6 +654,28 @@ private Join resolveLookupJoin(LookupJoin join) { | |
| return join; | ||
| } | ||
|
|
||
| // joining with remote cluster is not supported yet | ||
| if (join.left() instanceof EsRelation esr) { | ||
| for (var index : esr.index().concreteIndices()) { | ||
| if (index.indexOf(RemoteClusterAware.REMOTE_CLUSTER_INDEX_SEPARATOR) != -1) { | ||
|
||
| return join.withConfig( | ||
| new JoinConfig( | ||
| type, | ||
| List.of( | ||
| new UnresolvedAttribute( | ||
| join.source(), | ||
| "unsupported", | ||
| "LOOKUP JOIN does not support joining with remote cluster indices [" + esr.index().name() + "]" | ||
| ) | ||
| ), | ||
| List.of(), | ||
| List.of() | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| JoinType coreJoin = using.coreJoin(); | ||
| // verify the join type | ||
| if (coreJoin != JoinTypes.LEFT) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2250,6 +2250,24 @@ public void testLookupJoinIndexMode() { | |
| assertThat(e.getMessage(), containsString("1:25: invalid [test] resolution in lookup mode to an index in [standard] mode")); | ||
| } | ||
|
|
||
| public void testLookupJoinRemoteClusterUnsupported() { | ||
| assumeTrue("requires LOOKUP JOIN capability", EsqlCapabilities.Cap.JOIN_LOOKUP_V11.isEnabled()); | ||
|
|
||
| var remoteIndexResolution = loadMapping("mapping-default.json", "remote:my-index"); | ||
| var lookupResolution = AnalyzerTestUtils.defaultLookupResolution(); | ||
| VerificationException e = expectThrows( | ||
| VerificationException.class, | ||
| () -> analyze( | ||
| "FROM remote:my-index | LOOKUP JOIN languages_lookup ON language_code", | ||
|
||
| AnalyzerTestUtils.analyzer(remoteIndexResolution, lookupResolution) | ||
| ) | ||
| ); | ||
| assertThat( | ||
| e.getMessage(), | ||
| containsString("1:24: LOOKUP JOIN does not support joining with remote cluster indices [remote:my-index]") | ||
| ); | ||
| } | ||
|
|
||
| public void testImplicitCasting() { | ||
| var e = expectThrows(VerificationException.class, () -> analyze(""" | ||
| from test | eval x = concat("2024", "-04", "-01") + 1 day | ||
|
|
||
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 too specific. I think it will not work in case of queries like
Because the join's left child will not be an
EsRelation. TheEsRelationcan be many levels down in the tree.I'd approach this differently:
EsRelation.IndexMode.LOOKUP, a lookup join happens.EsRelationsmustn't be remote. We can just iterate over allEsRelations and check their concrete indices.Since my suggestion is a more global approach, I'd place this in the
Verifieras a separate verification step, rather than here in theAnalyzer. Reason: there can be multipleLOOKUP JOINs and we'll be re-checking theEsRelationin theFROMclause every time.We have tools to easily traverse query plans, collect nodes that are instanceof a certain class, and I think also getting only the plan's leaves. Take a look at the
transformDownmethods and similar methods in the same class. You can also take a peek atReplaceMissingFieldWithNullwhich needs to scan the plan for lookups as well.