1010import org .elasticsearch .index .IndexMode ;
1111import org .elasticsearch .test .ESTestCase ;
1212import org .elasticsearch .xpack .esql .EsqlTestUtils ;
13+ import org .elasticsearch .xpack .esql .action .EsqlCapabilities ;
1314import org .elasticsearch .xpack .esql .analysis .Analyzer ;
1415import org .elasticsearch .xpack .esql .analysis .AnalyzerContext ;
1516import org .elasticsearch .xpack .esql .analysis .AnalyzerTestUtils ;
@@ -115,6 +116,7 @@ private LogicalPlan localPlan(String query) {
115116 }
116117
117118 public void testSimple () {
119+ assumeTrue ("requires metrics command" , EsqlCapabilities .Cap .METRICS_COMMAND .isEnabled ());
118120 LogicalPlan actual = localPlan ("""
119121 TS test
120122 | STATS max(max_over_time(metric_1))
@@ -144,7 +146,7 @@ public void testRuleDoesNotApplyInNonTSMode() {
144146 }
145147
146148 public void testDimensionsAreNotFiltered () {
147-
149+ assumeTrue ( "requires metrics command" , EsqlCapabilities . Cap . METRICS_COMMAND . isEnabled ());
148150 LogicalPlan actual = localPlan ("""
149151 TS test
150152 | STATS max(max_over_time(metric_1)) BY dimension_1
@@ -161,7 +163,7 @@ public void testDimensionsAreNotFiltered() {
161163 }
162164
163165 public void testFiltersAreJoinedWithOr () {
164-
166+ assumeTrue ( "requires metrics command" , EsqlCapabilities . Cap . METRICS_COMMAND . isEnabled ());
165167 LogicalPlan actual = localPlan ("""
166168 TS test
167169 | STATS max(max_over_time(metric_1)), min(min_over_time(metric_2))
@@ -197,6 +199,7 @@ public void testFiltersAreJoinedWithOr() {
197199 public void testSkipCoalescedMetrics () {
198200 // Note: this test is passing because the reference attribute metric_2 in the stats block does not inherit the
199201 // metric property from the original field.
202+ assumeTrue ("requires metrics command" , EsqlCapabilities .Cap .METRICS_COMMAND .isEnabled ());
200203 LogicalPlan actual = localPlan ("""
201204 TS test
202205 | EVAL metric_2 = coalesce(metric_2, 0)
@@ -218,6 +221,7 @@ public void testSkipCoalescedMetrics() {
218221 * check that stats blocks after the first are not sourced for adding metrics to the filter
219222 */
220223 public void testMultipleStats () {
224+ assumeTrue ("requires metrics command" , EsqlCapabilities .Cap .METRICS_COMMAND .isEnabled ());
221225 LogicalPlan actual = localPlan ("""
222226 TS test
223227 | STATS m = max(max_over_time(metric_1))
@@ -232,6 +236,5 @@ public void testMultipleStats() {
232236 IsNotNull condition = as (filter .condition (), IsNotNull .class );
233237 FieldAttribute attribute = as (condition .field (), FieldAttribute .class );
234238 assertEquals ("metric_1" , attribute .fieldName ().string ());
235-
236239 }
237240}
0 commit comments