Skip to content

Commit bf837d9

Browse files
authored
Merge branch 'main' into esql-MV_CONTAINS_ALL
2 parents 88bd226 + 8dca924 commit bf837d9

File tree

15 files changed

+52
-38
lines changed

15 files changed

+52
-38
lines changed

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
1010

1111
import org.apache.http.util.EntityUtils;
12-
import org.elasticsearch.Build;
1312
import org.elasticsearch.client.Request;
1413
import org.elasticsearch.client.Response;
1514
import org.elasticsearch.common.settings.Settings;
@@ -18,6 +17,7 @@
1817
import org.elasticsearch.test.rest.ESRestTestCase;
1918
import org.elasticsearch.xpack.esql.AssertWarnings;
2019
import org.elasticsearch.xpack.esql.CsvTestsDataLoader;
20+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
2121
import org.elasticsearch.xpack.esql.qa.rest.ProfileLogger;
2222
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
2323
import org.junit.ClassRule;
@@ -48,7 +48,7 @@ protected String getTestRestCluster() {
4848
}
4949

5050
public void testTimeSeriesQuerying() throws IOException {
51-
assumeTrue("time series querying relies on query pragma", Build.current().isSnapshot());
51+
assumeTrue("time series querying relies on query pragma", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
5252
var settings = Settings.builder()
5353
.loadFromStream("tsdb-settings.json", TSDBRestEsqlIT.class.getResourceAsStream("/tsdb-settings.json"), false)
5454
.build();

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,20 @@ public static Iterable<Object[]> parameters() {
149149
new Object[] {
150150
new Test(
151151
"TS time_series_idx | LIMIT 10",
152-
Build.current().isSnapshot() ? Map.ofEntries(Map.entry("TS", 1), Map.entry("LIMIT", 1)) : Collections.emptyMap(),
152+
EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled()
153+
? Map.ofEntries(Map.entry("TS", 1), Map.entry("LIMIT", 1))
154+
: Collections.emptyMap(),
153155
Map.ofEntries(),
154-
Build.current().isSnapshot()
156+
EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled()
155157
) },
156158
new Object[] {
157159
new Test(
158160
"TS time_series_idx | STATS max(id) BY host | LIMIT 10",
159-
Build.current().isSnapshot()
161+
EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled()
160162
? Map.ofEntries(Map.entry("TS", 1), Map.entry("STATS", 1), Map.entry("LIMIT", 1))
161163
: Collections.emptyMap(),
162-
Build.current().isSnapshot() ? Map.ofEntries(Map.entry("MAX", 1)) : Collections.emptyMap(),
163-
Build.current().isSnapshot()
164+
EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled() ? Map.ofEntries(Map.entry("MAX", 1)) : Collections.emptyMap(),
165+
EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled()
164166
) },
165167
new Object[] {
166168
new Test(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.esql.action;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.common.Randomness;
1211
import org.elasticsearch.common.settings.Settings;
1312
import org.elasticsearch.common.unit.ByteSizeValue;
@@ -38,7 +37,7 @@ public class TimeSeriesIT extends AbstractEsqlIntegTestCase {
3837

3938
@Override
4039
public EsqlQueryResponse run(EsqlQueryRequest request) {
41-
assumeTrue("time series available in snapshot builds only", Build.current().isSnapshot());
40+
assumeTrue("time series available in snapshot builds only", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
4241
return super.run(request);
4342
}
4443

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.esql.action;
99

10-
import org.elasticsearch.Build;
1110
import org.elasticsearch.common.Randomness;
1211
import org.elasticsearch.common.settings.Settings;
1312
import org.elasticsearch.xpack.esql.EsqlTestUtils;
@@ -28,7 +27,7 @@ public class TimeSeriesRateIT extends AbstractEsqlIntegTestCase {
2827

2928
@Override
3029
public EsqlQueryResponse run(EsqlQueryRequest request) {
31-
assumeTrue("time series available in snapshot builds only", Build.current().isSnapshot());
30+
assumeTrue("time series available in snapshot builds only", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
3231
return super.run(request);
3332
}
3433

x-pack/plugin/esql/src/main/antlr/lexer/From.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ lexer grammar From;
1111
//
1212
FROM : 'from' -> pushMode(FROM_MODE);
1313

14-
DEV_TIME_SERIES : {this.isDevVersion()}? 'ts' -> pushMode(FROM_MODE);
14+
DEV_TIME_SERIES : {this.hasMetricsCommand()}? 'ts' -> pushMode(FROM_MODE);
1515

1616
mode FROM_MODE;
1717
FROM_PIPE : PIPE -> type(PIPE), popMode;

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
package org.elasticsearch.xpack.esql.parser;
99

1010
import org.elasticsearch.Build;
11+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1112

1213
class EsqlConfig {
1314

1415
// versioning information
1516
boolean devVersion = Build.current().isSnapshot();
1617

18+
boolean metricsCommand = EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled();
19+
1720
public boolean isDevVersion() {
1821
return devVersion;
1922
}
@@ -25,4 +28,12 @@ boolean isReleaseVersion() {
2528
public void setDevVersion(boolean dev) {
2629
this.devVersion = dev;
2730
}
31+
32+
public boolean hasMetricsCommand() {
33+
return metricsCommand;
34+
}
35+
36+
public void setMetricsCommand(boolean metricsCommand) {
37+
this.metricsCommand = metricsCommand;
38+
}
2839
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ boolean isDevVersion() {
2828
return config == null || config.isDevVersion();
2929
}
3030

31+
boolean hasMetricsCommand() {
32+
return config == null || config.hasMetricsCommand();
33+
}
34+
3135
void setEsqlConfig(EsqlConfig config) {
3236
this.config = config;
3337
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ private static Tuple<Mode, String> parsePolicyName(EsqlBaseParser.EnrichPolicyNa
551551

552552
@Override
553553
public LogicalPlan visitTimeSeriesCommand(EsqlBaseParser.TimeSeriesCommandContext ctx) {
554-
if (Build.current().isSnapshot() == false) {
554+
if (EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled() == false) {
555555
throw new IllegalArgumentException("TS command currently requires a snapshot build");
556556
}
557557
return visitRelation(source(ctx), IndexMode.TIME_SERIES, ctx.indexPatternAndMetadataFields());

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/AnalyzerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2472,7 +2472,7 @@ public void testNoDenseVectorFailsForMagnitude() {
24722472
}
24732473

24742474
public void testRateRequiresCounterTypes() {
2475-
assumeTrue("rate requires snapshot builds", Build.current().isSnapshot());
2475+
assumeTrue("rate requires snapshot builds", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
24762476
Analyzer analyzer = analyzer(tsdbIndexResolution());
24772477
var query = "TS test | STATS avg(rate(network.connections))";
24782478
VerificationException error = expectThrows(VerificationException.class, () -> analyze(query, analyzer));

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ public void testAggsResolutionWithUnresolvedGroupings() {
11391139
}
11401140

11411141
public void testNotAllowRateOutsideMetrics() {
1142-
assumeTrue("requires snapshot builds", Build.current().isSnapshot());
1142+
assumeTrue("requires metric command", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
11431143
assertThat(
11441144
error("FROM tests | STATS avg(rate(network.bytes_in))", tsdb),
11451145
equalTo("1:24: time_series aggregate[rate(network.bytes_in)] can only be used with the TS command")
@@ -1159,7 +1159,7 @@ public void testNotAllowRateOutsideMetrics() {
11591159
}
11601160

11611161
public void testRateNotEnclosedInAggregate() {
1162-
assumeTrue("requires snapshot builds", Build.current().isSnapshot());
1162+
assumeTrue("requires metric command", EsqlCapabilities.Cap.METRICS_COMMAND.isEnabled());
11631163
assertThat(
11641164
error("TS tests | STATS rate(network.bytes_in)", tsdb),
11651165
equalTo("1:18: the rate aggregate [rate(network.bytes_in)] can only be used with the TS command and inside another aggregate")

0 commit comments

Comments
 (0)