Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void testMetadataCrossClusterQuery() {
assertThat(e.getMessage(), containsString(LICENSE_ERROR_MESSAGE));
}

@AwaitsFix(bugUrl = "es-12487")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an interesting issue.
This test verifies index resolution with something like FROM fake-remote:events.

Field caps relies on returnLocalAll = true at

final Map<String, OriginalIndices> remoteClusterIndices = transportService.getRemoteClusterService()
.groupIndices(request.indicesOptions(), request.indices());

that causes it to return all indices from local clusters when all remotes are not found.

There are existing issues about it: #115262 and #115872

Today this flag is not exposed via FieldCapabilitiesRequest so I am not sure how this could be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Depends on #134284

public void testQueryAgainstNonMatchingClusterWildcardPattern() {
Tuple<Boolean, Boolean> includeCCSMetadata = randomIncludeCCSMetadata();
Boolean requestIncludeMeta = includeCCSMetadata.v1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,24 @@ public void testSearchesAgainstNonMatchingIndices() throws Exception {
// an error is thrown if there is a concrete index that does not match
{
String q = "FROM nomatch*,cluster-a:nomatch";
String expectedError = "Unknown index [cluster-a:nomatch,nomatch*]";
String expectedError = "Unknown index [nomatch*,cluster-a:nomatch]";
expectVerificationExceptionForQuery(q, expectedError, requestIncludeMeta);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here and in 3 below cases the error message index now matches the original input (notice that the order was different).

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ordering stable - i.e. is it going to always match original order, no matter how many patterns and clusters we have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, error uses indexPattern. We are supplying original user input into it now.

}

// an error is thrown if there are no matching indices at all - local with wildcard, remote with wildcard
{
String q = "FROM nomatch*,cluster-a:nomatch*";
String expectedError = "Unknown index [cluster-a:nomatch*,nomatch*]";
String expectedError = "Unknown index [nomatch*,cluster-a:nomatch*]";
expectVerificationExceptionForQuery(q, expectedError, requestIncludeMeta);
}
{
String q = "FROM nomatch,cluster-a:nomatch";
String expectedError = "Unknown index [cluster-a:nomatch,nomatch]";
String expectedError = "Unknown index [nomatch,cluster-a:nomatch]";
expectVerificationExceptionForQuery(q, expectedError, requestIncludeMeta);
}
{
String q = "FROM nomatch,cluster-a:nomatch*";
String expectedError = "Unknown index [cluster-a:nomatch*,nomatch]";
String expectedError = "Unknown index [nomatch,cluster-a:nomatch*]";
expectVerificationExceptionForQuery(q, expectedError, requestIncludeMeta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,23 +633,10 @@ private void preAnalyzeMainIndices(
ThreadPool.Names.SEARCH_COORDINATION,
ThreadPool.Names.SYSTEM_READ
);
// TODO we plan to support joins in the future when possible, but for now we'll just fail early if we see one
List<IndexPattern> indices = preAnalysis.indices;
if (indices.size() > 1) {
// Note: JOINs are not supported but we detect them when
listener.onFailure(new MappingException("Queries with multiple indices are not supported"));
} else if (indices.size() == 1) {
IndexPattern table = indices.getFirst();

// if the preceding call to the enrich policy API found unavailable clusters, recreate the index expression to search
// based only on available clusters (which could now be an empty list)
String indexExpressionToResolve = EsqlCCSUtils.createIndexExpressionFromAvailableClusters(executionInfo);
if (indexExpressionToResolve.isEmpty()) {
// if this was a pure remote CCS request (no local indices) and all remotes are offline, return an empty IndexResolution
listener.onResponse(
result.withIndexResolution(IndexResolution.valid(new EsIndex(table.indexPattern(), Map.of(), Map.of())))
);
} else {
switch (preAnalysis.indices.size()) {
// occurs when dealing with local relations (row a = 1)
case 0 -> listener.onResponse(result.withIndexResolution(IndexResolution.invalid("[none specified]")));
case 1 -> {
boolean includeAllDimensions = false;
// call the EsqlResolveFieldsAction (field-caps) to resolve indices and get field types
if (preAnalysis.indexMode == IndexMode.TIME_SERIES) {
Expand All @@ -663,7 +650,7 @@ private void preAnalyzeMainIndices(
}
}
indexResolver.resolveAsMergedMapping(
indexExpressionToResolve,
preAnalysis.indices.getFirst().indexPattern(),
result.fieldNames,
requestFilter,
includeAllDimensions,
Expand All @@ -672,13 +659,8 @@ private void preAnalyzeMainIndices(
})
);
}
} else {
try {
// occurs when dealing with local relations (row a = 1)
listener.onResponse(result.withIndexResolution(IndexResolution.invalid("[none specified]")));
} catch (Exception ex) {
listener.onFailure(ex);
}
// Note: JOINs are not supported but we detect them when
default -> listener.onFailure(new MappingException("Queries with multiple indices are not supported"));
}
}

Expand Down