diff --git a/table-api/src/main/java/io/deephaven/api/agg/Aggregation.java b/table-api/src/main/java/io/deephaven/api/agg/Aggregation.java index 7c2b6a45b9e..72718229f34 100644 --- a/table-api/src/main/java/io/deephaven/api/agg/Aggregation.java +++ b/table-api/src/main/java/io/deephaven/api/agg/Aggregation.java @@ -72,6 +72,10 @@ static Aggregation of(AggSpec spec, String... pairs) { * @return The aggregation */ static Aggregation of(AggSpec spec, List pairs) { + if (pairs.isEmpty()) { + throw new IllegalArgumentException( + "Must have at least one pair to create an Aggregation from an AggSpec. Did you mean to use TableOperations#aggAllBy?"); + } if (pairs.size() == 1) { return of(spec, pairs.get(0)); } @@ -89,6 +93,9 @@ static Aggregation of(AggSpec spec, List pairs) { * @return The combined aggregation */ static Aggregation of(Aggregation... aggregations) { + if (aggregations.length == 0) { + throw new IllegalArgumentException("Unable to create an empty aggregation."); + } if (aggregations.length == 1) { return aggregations[0]; } @@ -108,6 +115,9 @@ static Aggregation of(Aggregation... aggregations) { @SafeVarargs static Aggregation of(BiFunction columnAggFactory, String inputColumn, INPUT_TYPE... inputs) { + if (inputs.length == 0) { + throw new IllegalArgumentException("Unable to create an empty aggregation."); + } final ColumnName inputColumnName = ColumnName.of(inputColumn); if (inputs.length == 1) { return columnAggFactory.apply(inputColumnName, inputs[0]); diff --git a/table-api/src/main/java/io/deephaven/api/agg/Aggregations.java b/table-api/src/main/java/io/deephaven/api/agg/Aggregations.java index 529a3ce75e6..fe65a22e26c 100644 --- a/table-api/src/main/java/io/deephaven/api/agg/Aggregations.java +++ b/table-api/src/main/java/io/deephaven/api/agg/Aggregations.java @@ -32,8 +32,8 @@ public final V walk(V visitor) { @Check final void checkSize() { if (aggregations().size() < 2) { - throw new IllegalArgumentException( - String.format("%s should have at least two aggregations", Aggregations.class)); + throw new IllegalArgumentException(String.format("%s should have at least two aggregations, has %d", + Aggregations.class, aggregations().size())); } } diff --git a/table-api/src/main/java/io/deephaven/api/agg/ColumnAggregations.java b/table-api/src/main/java/io/deephaven/api/agg/ColumnAggregations.java index 231ef4b90ae..59f678b2fb0 100644 --- a/table-api/src/main/java/io/deephaven/api/agg/ColumnAggregations.java +++ b/table-api/src/main/java/io/deephaven/api/agg/ColumnAggregations.java @@ -36,8 +36,8 @@ public final V walk(V visitor) { @Check final void checkSize() { if (pairs().size() < 2) { - throw new IllegalArgumentException( - String.format("%s should have at least two pairs", ColumnAggregations.class)); + throw new IllegalArgumentException(String.format("%s should have at least two pairs, has %d", + ColumnAggregations.class, pairs().size())); } }