Skip to content

Commit ebac5de

Browse files
authored
[ESQL] Fix init value in max float aggregation (elastic#113699) (elastic#113707)
We are current using Float.MIN_VALUE which is the smallest positive non-zero value, not the smallest possible value. This commit change it to -Float.MAX_VALUE to be symmetric to the double max aggregation.
1 parent 8b67b04 commit ebac5de

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/changelog/113699.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 113699
2+
summary: "[ESQL] Fix init value in max float aggregation"
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/MaxFloatAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class MaxFloatAggregator {
1717

1818
public static float init() {
19-
return Float.MIN_VALUE;
19+
return -Float.MAX_VALUE;
2020
}
2121

2222
public static float combine(float current, float v) {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/MaxFloatGroupingAggregatorFunctionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public class MaxFloatGroupingAggregatorFunctionTests extends GroupingAggregatorF
2727
protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
2828
return new LongFloatTupleBlockSourceOperator(
2929
blockFactory,
30-
LongStream.range(0, end).mapToObj(l -> Tuple.tuple(randomLongBetween(0, 4), randomFloat()))
30+
LongStream.range(0, end)
31+
.mapToObj(l -> Tuple.tuple(randomLongBetween(0, 4), randomFloatBetween(-Float.MAX_VALUE, Float.MAX_VALUE, true)))
3132
);
3233
}
3334

0 commit comments

Comments
 (0)