diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/TimeSeriesGroupByAll.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/TimeSeriesGroupByAll.java index a29da40031d45..e2934c414c400 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/TimeSeriesGroupByAll.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/TimeSeriesGroupByAll.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.esql.analysis; -import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException; import org.elasticsearch.xpack.esql.core.expression.Alias; import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.core.expression.Expression; @@ -67,10 +66,13 @@ public LogicalPlan rule(TimeSeriesAggregate aggregate) { } if (lastNonTSAggFunction != null) { - throw new EsqlIllegalArgumentException( - "Cannot mix time-series aggregate [{}] and regular aggregate [{}] in the same TimeSeriesAggregate.", - lastTSAggFunction.sourceText(), - lastNonTSAggFunction.sourceText() + throw new IllegalArgumentException( + "Cannot mix time-series aggregate [" + + lastTSAggFunction.sourceText() + + "] and regular aggregate [" + + lastNonTSAggFunction.sourceText() + + "] in the same TimeSeriesAggregate." + ); } @@ -86,9 +88,9 @@ public LogicalPlan rule(TimeSeriesAggregate aggregate) { for (Expression grouping : aggregate.groupings()) { if (Functions.isGrouping(Alias.unwrap(grouping)) == false) { - throw new EsqlIllegalArgumentException( - "Cannot mix time-series aggregate and grouping attributes. Found [{}].", - grouping.sourceText() + throw new IllegalArgumentException( + "Cannot mix time-series aggregate and grouping attributes. Found [" + grouping.sourceText() + "]." + ); } groupings.add(grouping); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/TimeSeriesBareAggregationsTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/TimeSeriesBareAggregationsTests.java index 1045ad30b0d7b..29fb332e80867 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/TimeSeriesBareAggregationsTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/TimeSeriesBareAggregationsTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.index.IndexMode; -import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException; import org.elasticsearch.xpack.esql.EsqlTestUtils; import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.elasticsearch.xpack.esql.analysis.Analyzer; @@ -264,7 +263,7 @@ public void testCountOverTime() { public void testMixedBareOverTimeAndRegularAggregates() { assumeTrue("requires metrics command", EsqlCapabilities.Cap.METRICS_GROUP_BY_ALL.isEnabled()); - var error = expectThrows(EsqlIllegalArgumentException.class, () -> { planK8s(""" + var error = expectThrows(IllegalArgumentException.class, () -> { planK8s(""" TS k8s | STATS avg_over_time(network.cost), sum(network.total_bytes_in) """); }); @@ -277,7 +276,7 @@ public void testMixedBareOverTimeAndRegularAggregates() { public void testGroupingKeyInAggregatesListPreserved() { assumeTrue("requires metrics command", EsqlCapabilities.Cap.METRICS_GROUP_BY_ALL.isEnabled()); - var error = expectThrows(EsqlIllegalArgumentException.class, () -> { planK8s(""" + var error = expectThrows(IllegalArgumentException.class, () -> { planK8s(""" TS k8s | STATS rate(network.total_bytes_out) BY region, TBUCKET(1hour) """); });