From 4d6f1952f53b92bb941ff503816baa261447f099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Cea=20Fontenla?= Date: Thu, 10 Oct 2024 11:02:05 +0200 Subject: [PATCH] Reduce double and float precision requirements on rest CSV tests (#114313) Fixes https://github.com/elastic/elasticsearch-serverless/issues/2837 The failing value is `5.801464200000001`, which rounds to `5.8014642`. However, `5.8014642` is roudned to `5.801464199`. With a precision of 7, both are truncated to `5.801464`. Not the most elegant solution, but it works for this case, which may be a quite edgy one. --- .../elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index 1543ba039dc6d..319e67512c7ac 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -279,9 +279,9 @@ private Object valueMapper(CsvTestUtils.Type type, Object value) { } return values; } else if (value instanceof Double d) { - return new BigDecimal(d).round(new MathContext(10, RoundingMode.DOWN)).doubleValue(); + return new BigDecimal(d).round(new MathContext(7, RoundingMode.DOWN)).doubleValue(); } else if (value instanceof String s) { - return new BigDecimal(s).round(new MathContext(10, RoundingMode.DOWN)).doubleValue(); + return new BigDecimal(s).round(new MathContext(7, RoundingMode.DOWN)).doubleValue(); } } return value.toString();