Skip to content

Commit a9ee692

Browse files
authored
Merge branch 'main' into entitlements/fix-multiple-version-checker-initialization-2
2 parents 7b6abbb + aac1409 commit a9ee692

File tree

20 files changed

+2206
-2187
lines changed

20 files changed

+2206
-2187
lines changed

docs/changelog/121193.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pr: 121193
2+
summary: Enable LOOKUP JOIN in non-snapshot builds
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 121185
7+
highlight:
8+
title: Enable LOOKUP JOIN in non-snapshot builds
9+
body: |-
10+
This effectively releases LOOKUP JOIN into tech preview. Docs will
11+
follow in a separate PR.
12+
13+
- Enable the lexing/grammar for LOOKUP JOIN in non-snapshot builds.
14+
- Remove the grammar for the unsupported `| JOIN ...` command (without `LOOKUP` as first keyword). The way the lexer modes work, otherwise we'd also have to enable `| JOIN ...` syntax on non-snapshot builds and would have to add additional validation to provide appropriate error messages.
15+
- Remove grammar for `LOOKUP JOIN index AS ...` because qualifiers are not yet supported. Otherwise we'd have to put in additional validation as well to prevent such queries.
16+
17+
Also fix https://github.com/elastic/elasticsearch/issues/121185
18+
notable: true

docs/changelog/121283.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 121283
2+
summary: Cheaper snapshot-related `toString()` impls
3+
area: Snapshot/Restore
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ tests:
314314
- class: org.elasticsearch.xpack.security.profile.ProfileIntegTests
315315
method: testSetEnabled
316316
issue: https://github.com/elastic/elasticsearch/issues/121183
317-
- class: org.elasticsearch.xpack.esql.optimizer.LogicalPlanOptimizerTests
318-
issue: https://github.com/elastic/elasticsearch/issues/121185
319317
- class: org.elasticsearch.xpack.security.CoreWithSecurityClientYamlTestSuiteIT
320318
method: test {yaml=cat.aliases/10_basic/Simple alias}
321319
issue: https://github.com/elastic/elasticsearch/issues/121186
@@ -372,6 +370,9 @@ tests:
372370
issue: https://github.com/elastic/elasticsearch/issues/121293
373371
- class: org.elasticsearch.xpack.inference.common.InferenceServiceNodeLocalRateLimitCalculatorTests
374372
issue: https://github.com/elastic/elasticsearch/issues/121294
373+
- class: org.elasticsearch.entitlement.runtime.policy.PolicyManagerTests
374+
method: testDuplicateFlagEntitlements
375+
issue: https://github.com/elastic/elasticsearch/issues/121300
375376

376377
# Examples:
377378
#

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotsServiceIT.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
import org.elasticsearch.cluster.SnapshotDeletionsInProgress;
1818
import org.elasticsearch.cluster.metadata.IndexMetadata;
1919
import org.elasticsearch.cluster.service.ClusterService;
20+
import org.elasticsearch.cluster.service.MasterService;
2021
import org.elasticsearch.common.settings.Settings;
2122
import org.elasticsearch.snapshots.mockstore.MockRepository;
2223
import org.elasticsearch.test.ClusterServiceUtils;
2324
import org.elasticsearch.test.MockLog;
25+
import org.elasticsearch.test.junit.annotations.TestLogging;
2426

2527
import java.util.List;
2628
import java.util.concurrent.TimeUnit;
@@ -223,4 +225,30 @@ public void testRerouteWhenShardSnapshotsCompleted() throws Exception {
223225
safeAwait(shardMovedListener);
224226
ensureGreen(indexName);
225227
}
228+
229+
@TestLogging(reason = "testing task description, logged at DEBUG", value = "org.elasticsearch.cluster.service.MasterService:DEBUG")
230+
public void testCreateSnapshotTaskDescription() {
231+
createIndexWithRandomDocs(randomIdentifier(), randomIntBetween(1, 5));
232+
final var repositoryName = randomIdentifier();
233+
createRepository(repositoryName, "mock");
234+
235+
final var snapshotName = randomIdentifier();
236+
MockLog.assertThatLogger(
237+
() -> createFullSnapshot(repositoryName, snapshotName),
238+
MasterService.class,
239+
new MockLog.SeenEventExpectation(
240+
"executing cluster state update debug message",
241+
MasterService.class.getCanonicalName(),
242+
Level.DEBUG,
243+
"executing cluster state update for [create_snapshot ["
244+
+ snapshotName
245+
+ "][CreateSnapshotTask{repository="
246+
+ repositoryName
247+
+ ", snapshot=*"
248+
+ snapshotName
249+
+ "*}]]"
250+
)
251+
);
252+
}
253+
226254
}

server/src/main/java/org/elasticsearch/repositories/RepositoryData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@ public int hashCode() {
605605
return Objects.hash(snapshotIds, snapshotsDetails, indices, indexSnapshots, shardGenerations, indexMetaDataGenerations);
606606
}
607607

608+
@Override
609+
public String toString() {
610+
return Strings.format("RepositoryData[uuid=%s,gen=%s]", uuid, genId);
611+
}
612+
608613
/**
609614
* Resolve the index name to the index id specific to the repository,
610615
* throwing an exception if the index could not be resolved.

server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,11 @@ public void onFailure(Exception e) {
38853885
logSnapshotFailure("create", snapshot, e);
38863886
listener.onFailure(e);
38873887
}
3888+
3889+
@Override
3890+
public String toString() {
3891+
return "CreateSnapshotTask{repository=" + repository.getMetadata().name() + ", snapshot=" + snapshot + '}';
3892+
}
38883893
}
38893894

38903895
private static void logSnapshotFailure(String operation, Snapshot snapshot, Exception e) {

server/src/test/java/org/elasticsearch/repositories/RepositoryDataTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040

4141
import static org.elasticsearch.repositories.RepositoryData.EMPTY_REPO_GEN;
4242
import static org.elasticsearch.repositories.RepositoryData.MISSING_UUID;
43+
import static org.hamcrest.Matchers.allOf;
4344
import static org.hamcrest.Matchers.containsInAnyOrder;
45+
import static org.hamcrest.Matchers.containsString;
4446
import static org.hamcrest.Matchers.equalTo;
4547
import static org.hamcrest.Matchers.greaterThan;
48+
import static org.hamcrest.Matchers.not;
4649

4750
/**
4851
* Tests for the {@link RepositoryData} class.
@@ -430,6 +433,19 @@ public void testFailsIfMinVersionNotSatisfied() throws IOException {
430433
}
431434
}
432435

436+
public void testToString() {
437+
final var repositoryData = generateRandomRepoData();
438+
assertThat(
439+
repositoryData.toString(),
440+
allOf(
441+
containsString("RepositoryData"),
442+
containsString(repositoryData.getUuid()),
443+
containsString(Long.toString(repositoryData.getGenId())),
444+
not(containsString("@")) // not the default Object#toString which does a very expensive hashcode computation
445+
)
446+
);
447+
}
448+
433449
public static RepositoryData generateRandomRepoData() {
434450
final int numIndices = randomIntBetween(1, 30);
435451
final List<IndexId> indices = new ArrayList<>(numIndices);

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ protected boolean supportsIndexModeLookup() throws IOException {
232232
protected final void doTest() throws Throwable {
233233
RequestObjectBuilder builder = new RequestObjectBuilder(randomFrom(XContentType.values()));
234234

235-
if (testCase.query.toUpperCase(Locale.ROOT).contains("LOOKUP")) {
235+
if (testCase.query.toUpperCase(Locale.ROOT).contains("LOOKUP_\uD83D\uDC14")) {
236236
builder.tables(tables());
237237
}
238238

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TelemetryIT.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,9 @@ public static Iterable<Object[]> parameters() {
142142
| EVAL y = to_str(host)
143143
| LOOKUP JOIN lookup_idx ON host
144144
""",
145-
Build.current().isSnapshot()
146-
? Map.ofEntries(Map.entry("FROM", 1), Map.entry("EVAL", 1), Map.entry("LOOKUP JOIN", 1))
147-
: Collections.emptyMap(),
148-
Build.current().isSnapshot() ? Map.ofEntries(Map.entry("TO_STRING", 1)) : Collections.emptyMap(),
149-
Build.current().isSnapshot()
145+
Map.ofEntries(Map.entry("FROM", 1), Map.entry("EVAL", 1), Map.entry("LOOKUP JOIN", 1)),
146+
Map.ofEntries(Map.entry("TO_STRING", 1)),
147+
true
150148
) },
151149
new Object[] {
152150
new Test(

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ SHOW : 'show' -> pushMode(SHOW_MODE);
7373
SORT : 'sort' -> pushMode(EXPRESSION_MODE);
7474
STATS : 'stats' -> pushMode(EXPRESSION_MODE);
7575
WHERE : 'where' -> pushMode(EXPRESSION_MODE);
76+
JOIN_LOOKUP : 'lookup' -> pushMode(JOIN_MODE);
7677
//
7778
// in development
7879
//
@@ -88,11 +89,9 @@ DEV_INLINESTATS : {this.isDevVersion()}? 'inlinestats' -> pushMode(EXPRESSION_
8889
DEV_LOOKUP : {this.isDevVersion()}? 'lookup_🐔' -> pushMode(LOOKUP_MODE);
8990
DEV_METRICS : {this.isDevVersion()}? 'metrics' -> pushMode(METRICS_MODE);
9091
// list of all JOIN commands
91-
DEV_JOIN : {this.isDevVersion()}? 'join' -> pushMode(JOIN_MODE);
9292
DEV_JOIN_FULL : {this.isDevVersion()}? 'full' -> pushMode(JOIN_MODE);
9393
DEV_JOIN_LEFT : {this.isDevVersion()}? 'left' -> pushMode(JOIN_MODE);
9494
DEV_JOIN_RIGHT : {this.isDevVersion()}? 'right' -> pushMode(JOIN_MODE);
95-
DEV_JOIN_LOOKUP : {this.isDevVersion()}? 'lookup' -> pushMode(JOIN_MODE);
9695

9796

9897
//
@@ -556,7 +555,7 @@ LOOKUP_FIELD_WS
556555
//
557556
mode JOIN_MODE;
558557
JOIN_PIPE : PIPE -> type(PIPE), popMode;
559-
JOIN_JOIN : DEV_JOIN -> type(DEV_JOIN);
558+
JOIN : 'join';
560559
JOIN_AS : AS -> type(AS);
561560
JOIN_ON : ON -> type(ON), popMode, pushMode(EXPRESSION_MODE);
562561
USING : 'USING' -> popMode, pushMode(EXPRESSION_MODE);

0 commit comments

Comments
 (0)