From 7ad03e8b96e9a09fcca04dd5c926abae6a69f5df Mon Sep 17 00:00:00 2001 From: Alex Kasko Date: Tue, 20 Oct 2026 17:10:59 +0100 Subject: [PATCH] Fix floating point comparison in Spark test --- src/test/external/RunSpark.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/external/RunSpark.java b/src/test/external/RunSpark.java index bd75f8e6d..37a44b517 100644 --- a/src/test/external/RunSpark.java +++ b/src/test/external/RunSpark.java @@ -18,7 +18,7 @@ public static void main(String[] args) throws Exception { System.out.print(output); int status = ps.waitFor(); String[] lines = output.split("\n"); - if (lines.length < 2 || !"7433139".equals(lines[0]) || !"1.429378704487457E8".equals(lines[1])) { + if (lines.length < 2 || !"7433139".equals(lines[0]) || !sumMatches(lines[1])) { throw new RuntimeException("Spark SQL test output check failed"); } if (status == 0) { @@ -27,6 +27,18 @@ public static void main(String[] args) throws Exception { System.exit(status); } + // Sum of FLOAT values depends on the order in which they are added, physical row order + // of the DuckLake table is not stable across setups, so the last digits can differ. + static boolean sumMatches(String line) { + double expected = 1.429378704487457E8; + try { + double actual = Double.parseDouble(line.trim()); + return Math.abs(actual - expected) <= Math.abs(expected) * 1e-9; + } catch (NumberFormatException e) { + return false; + } + } + static String fromEnv(String envVarName, String defaultValue) { String env = System.getenv(envVarName); if (null != env) {