Skip to content

Commit adb6344

Browse files
committed
fixup and comments
1 parent b89d53d commit adb6344

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,16 @@ public void testGroupBySubset() {
550550
} else {
551551
assertThat(row.getFirst(), equalTo(docValues.isEmpty() ? null : docValues.getFirst().longValue()));
552552
}
553-
assertThat(row.get(1), equalTo(aggregatePerTimeseries(tsGroups, Agg.MAX, Agg.MAX)));
554-
assertThat(row.get(2), equalTo(aggregatePerTimeseries(tsGroups, Agg.MIN, Agg.MIN)));
555-
assertThat(row.get(3), equalTo(aggregatePerTimeseries(tsGroups, Agg.SUM, Agg.COUNT)));
556-
assertThat(row.get(4), equalTo(aggregatePerTimeseries(tsGroups, Agg.SUM, Agg.SUM)));
553+
Function<Object, Double> toDouble = cell -> switch (cell) {
554+
case Long l -> l.doubleValue();
555+
case Double d -> d;
556+
case null -> null;
557+
default -> throw new IllegalStateException("Unexpected value type: " + cell + " of class " + cell.getClass());
558+
};
559+
assertThat(toDouble.apply(row.get(1)), equalTo(aggregatePerTimeseries(tsGroups, Agg.MAX, Agg.MAX)));
560+
assertThat(toDouble.apply(row.get(2)), equalTo(aggregatePerTimeseries(tsGroups, Agg.MIN, Agg.MIN)));
561+
assertThat(toDouble.apply(row.get(3)), equalTo(aggregatePerTimeseries(tsGroups, Agg.SUM, Agg.COUNT)));
562+
assertThat(toDouble.apply(row.get(4)), equalTo(aggregatePerTimeseries(tsGroups, Agg.SUM, Agg.SUM)));
557563
var avg = (Double) aggregatePerTimeseries(tsGroups, Agg.AVG, Agg.AVG);
558564
assertThat((Double) row.get(5), row.get(5) == null ? equalTo(null) : closeTo(avg, avg * 0.01));
559565
// assertThat(row.get(6), equalTo(aggregatePerTimeseries(tsGroups, Agg.COUNT, Agg.COUNT).longValue()));

0 commit comments

Comments
 (0)