Skip to content

Commit ec65d0b

Browse files
Merge branch 'main' into esql/fix_generative_tests_20250430
2 parents fa6845b + de68cb0 commit ec65d0b

File tree

18 files changed

+1722
-1333
lines changed

18 files changed

+1722
-1333
lines changed

benchmarks/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dependencies {
4242
api(project(':libs:h3'))
4343
api(project(':modules:aggregations'))
4444
api(project(':x-pack:plugin:esql-core'))
45+
api(project(':x-pack:plugin:core'))
4546
api(project(':x-pack:plugin:esql'))
4647
api(project(':x-pack:plugin:esql:compute'))
4748
implementation project(path: ':libs:simdvec')
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.benchmark.esql;
11+
12+
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.elasticsearch.common.settings.Settings;
14+
import org.elasticsearch.index.IndexMode;
15+
import org.elasticsearch.license.XPackLicenseState;
16+
import org.elasticsearch.xpack.esql.analysis.Analyzer;
17+
import org.elasticsearch.xpack.esql.analysis.AnalyzerContext;
18+
import org.elasticsearch.xpack.esql.analysis.EnrichResolution;
19+
import org.elasticsearch.xpack.esql.analysis.Verifier;
20+
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
21+
import org.elasticsearch.xpack.esql.core.type.EsField;
22+
import org.elasticsearch.xpack.esql.core.util.DateUtils;
23+
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
24+
import org.elasticsearch.xpack.esql.index.EsIndex;
25+
import org.elasticsearch.xpack.esql.index.IndexResolution;
26+
import org.elasticsearch.xpack.esql.inference.InferenceResolution;
27+
import org.elasticsearch.xpack.esql.optimizer.LogicalOptimizerContext;
28+
import org.elasticsearch.xpack.esql.optimizer.LogicalPlanOptimizer;
29+
import org.elasticsearch.xpack.esql.parser.EsqlParser;
30+
import org.elasticsearch.xpack.esql.parser.QueryParams;
31+
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
32+
import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;
33+
import org.elasticsearch.xpack.esql.plugin.QueryPragmas;
34+
import org.elasticsearch.xpack.esql.session.Configuration;
35+
import org.elasticsearch.xpack.esql.telemetry.Metrics;
36+
import org.elasticsearch.xpack.esql.telemetry.PlanTelemetry;
37+
import org.openjdk.jmh.annotations.Benchmark;
38+
import org.openjdk.jmh.annotations.BenchmarkMode;
39+
import org.openjdk.jmh.annotations.Fork;
40+
import org.openjdk.jmh.annotations.Measurement;
41+
import org.openjdk.jmh.annotations.Mode;
42+
import org.openjdk.jmh.annotations.OutputTimeUnit;
43+
import org.openjdk.jmh.annotations.Scope;
44+
import org.openjdk.jmh.annotations.Setup;
45+
import org.openjdk.jmh.annotations.State;
46+
import org.openjdk.jmh.annotations.Warmup;
47+
import org.openjdk.jmh.infra.Blackhole;
48+
49+
import java.util.LinkedHashMap;
50+
import java.util.Locale;
51+
import java.util.Map;
52+
import java.util.concurrent.TimeUnit;
53+
54+
import static java.util.Collections.emptyMap;
55+
import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT;
56+
57+
@Fork(1)
58+
@Warmup(iterations = 5)
59+
@Measurement(iterations = 10)
60+
@BenchmarkMode(Mode.AverageTime)
61+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
62+
@State(Scope.Benchmark)
63+
public class QueryPlanningBenchmark {
64+
65+
static {
66+
LogConfigurator.configureESLogging();
67+
}
68+
69+
private PlanTelemetry telemetry;
70+
private EsqlParser parser;
71+
private Analyzer analyzer;
72+
private LogicalPlanOptimizer optimizer;
73+
74+
@Setup
75+
public void setup() {
76+
77+
var config = new Configuration(
78+
DateUtils.UTC,
79+
Locale.US,
80+
null,
81+
null,
82+
new QueryPragmas(Settings.EMPTY),
83+
EsqlPlugin.QUERY_RESULT_TRUNCATION_MAX_SIZE.getDefault(Settings.EMPTY),
84+
EsqlPlugin.QUERY_RESULT_TRUNCATION_DEFAULT_SIZE.getDefault(Settings.EMPTY),
85+
"",
86+
false,
87+
Map.of(),
88+
System.nanoTime(),
89+
false
90+
);
91+
92+
var fields = 10_000;
93+
var mapping = LinkedHashMap.<String, EsField>newLinkedHashMap(fields);
94+
for (int i = 0; i < fields; i++) {
95+
mapping.put("field" + i, new EsField("field-" + i, TEXT, emptyMap(), true));
96+
}
97+
98+
var esIndex = new EsIndex("test", mapping, Map.of("test", IndexMode.STANDARD));
99+
100+
var functionRegistry = new EsqlFunctionRegistry();
101+
102+
telemetry = new PlanTelemetry(functionRegistry);
103+
parser = new EsqlParser();
104+
analyzer = new Analyzer(
105+
new AnalyzerContext(
106+
config,
107+
functionRegistry,
108+
IndexResolution.valid(esIndex),
109+
Map.of(),
110+
new EnrichResolution(),
111+
InferenceResolution.EMPTY
112+
),
113+
new Verifier(new Metrics(functionRegistry), new XPackLicenseState(() -> 0L))
114+
);
115+
optimizer = new LogicalPlanOptimizer(new LogicalOptimizerContext(config, FoldContext.small()));
116+
}
117+
118+
private LogicalPlan plan(String query) {
119+
var parsed = parser.createStatement(query, new QueryParams(), telemetry);
120+
var analyzed = analyzer.analyze(parsed);
121+
var optimized = optimizer.optimize(analyzed);
122+
return optimized;
123+
}
124+
125+
@Benchmark
126+
public void run(Blackhole blackhole) {
127+
blackhole.consume(plan("FROM test | LIMIT 10"));
128+
}
129+
}

docs/reference/query-languages/esql/_snippets/commands/layout/lookup-join.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ added as new columns to that row.
4141
If multiple documents in the lookup index match a single row in your
4242
results, the output will contain one row for each matching combination.
4343

44-
**Examples**
45-
4644
::::{tip}
4745
In case of name collisions, the newly created columns will override existing columns.
4846
::::
4947

48+
**Examples**
49+
5050
**IP Threat correlation**: This query would allow you to see if any source
5151
IPs match known malicious addresses.
5252

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,18 +429,9 @@ tests:
429429
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
430430
method: testLookupExplosionNoFetch
431431
issue: https://github.com/elastic/elasticsearch/issues/127365
432-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
433-
method: testNonLocalRequestAlwaysFindsMasterAndWaitsForMetadata
434-
issue: https://github.com/elastic/elasticsearch/issues/127422
435432
- class: org.elasticsearch.xpack.esql.qa.single_node.PushQueriesIT
436433
method: testPushCaseInsensitiveEqualityOnDefaults
437434
issue: https://github.com/elastic/elasticsearch/issues/127431
438-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
439-
method: testLocalRequestAlwaysSucceeds
440-
issue: https://github.com/elastic/elasticsearch/issues/127423
441-
- class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionDisruptionIT
442-
method: testLocalRequestWaitsForMetadata
443-
issue: https://github.com/elastic/elasticsearch/issues/127466
444435
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
445436
method: test {union_types.MultiIndexSortIpStringEval ASYNC}
446437
issue: https://github.com/elastic/elasticsearch/issues/127537

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@
2828
import java.util.Collection;
2929
import java.util.Collections;
3030
import java.util.List;
31+
import java.util.Optional;
3132
import java.util.concurrent.atomic.AtomicBoolean;
3233
import java.util.stream.Collectors;
3334
import java.util.stream.StreamSupport;
3435

3536
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING;
3637
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
37-
import static org.hamcrest.Matchers.equalTo;
3838
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
3939
import static org.hamcrest.Matchers.hasSize;
4040
import static org.hamcrest.Matchers.instanceOf;
41-
import static org.hamcrest.Matchers.not;
4241

4342
@ESIntegTestCase.ClusterScope(numDataNodes = 0, scope = ESIntegTestCase.Scope.TEST)
4443
public class TransportClusterStateActionDisruptionIT extends ESIntegTestCase {
@@ -212,11 +211,12 @@ public void runRepeatedlyWhileChangingMaster(Runnable runnable) throws Exception
212211
}
213212
}
214213

215-
assertBusy(() -> {
216-
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
217-
final String claimedMasterName = internalCluster().getMasterName(nonMasterNode);
218-
assertThat(claimedMasterName, not(equalTo(masterName)));
219-
});
214+
final String nonMasterNode = randomValueOtherThan(masterName, () -> randomFrom(internalCluster().getNodeNames()));
215+
awaitClusterState(
216+
logger,
217+
nonMasterNode,
218+
state -> Optional.ofNullable(state.nodes().getMasterNode()).map(m -> m.getName().equals(masterName) == false).orElse(false)
219+
);
220220

221221
shutdown.set(true);
222222
assertingThread.join();

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ field
8787
: (qualifiedName ASSIGN)? booleanExpression
8888
;
8989

90+
rerankFields
91+
: rerankField (COMMA rerankField)*
92+
;
93+
94+
rerankField
95+
: qualifiedName (ASSIGN booleanExpression)?
96+
;
97+
9098
fromCommand
9199
: FROM indexPatternAndMetadataFields
92100
;
@@ -296,7 +304,7 @@ rrfCommand
296304
;
297305

298306
rerankCommand
299-
: DEV_RERANK queryText=constant ON fields WITH inferenceId=identifierOrParameter
307+
: DEV_RERANK queryText=constant ON rerankFields WITH inferenceId=identifierOrParameter
300308
;
301309

302310
completionCommand

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseParser.interp

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)