Skip to content

Commit b470c9d

Browse files
authored
[ES|QL] Change rounding mode in tests to HALF_DOWN (#129895) (#129899)
The current rounding mode in some of the tests in ESQL uses DOWN which truncates more than rounds and can result in some tests failing with errors like `row 0 column 0:0: expected <0.05235999> but was <0.05236>` HALF_DOWN would round this up
1 parent aeb90db commit b470c9d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,9 @@ private Object valueMapper(CsvTestUtils.Type type, Object value) {
350350
}
351351
return values;
352352
} else if (value instanceof Double d) {
353-
return new BigDecimal(d).round(new MathContext(7, RoundingMode.DOWN)).doubleValue();
353+
return new BigDecimal(d).round(new MathContext(7, RoundingMode.HALF_DOWN)).doubleValue();
354354
} else if (value instanceof String s) {
355-
return new BigDecimal(s).round(new MathContext(7, RoundingMode.DOWN)).doubleValue();
355+
return new BigDecimal(s).round(new MathContext(7, RoundingMode.HALF_DOWN)).doubleValue();
356356
}
357357
}
358358
if (type == CsvTestUtils.Type.TEXT || type == CsvTestUtils.Type.KEYWORD || type == CsvTestUtils.Type.SEMANTIC_TEXT) {

0 commit comments

Comments
 (0)