From 37bc4a4572ad7c8178df5243b4db8b03df0572af Mon Sep 17 00:00:00 2001 From: Polyglot AI <293096396+polyglotAI-bot@users.noreply.github.com> Date: Tue, 28 Jul 2026 20:59:22 +0000 Subject: [PATCH] Fix flaky client-v2 testDynamicWithPrimitives: deterministic Decimal samples DataTypesTestingPOJO seeded its four Decimal fields with BigDecimal.valueOf(random.nextDouble()). When a small-magnitude random value's scale exceeded the scale inferred for a Dynamic Decimal column (the width is chosen from precision, but the scale is forced to that width's maximum), the value was rounded on write; the read-back value no longer equaled the original and the round-trip check divide(value, RoundingMode.UNNECESSARY) threw "Rounding necessary" (~1% of runs, seen on the ClickHouse 25.8 CI matrix). Use fixed Decimal samples whose scale fits each inferred width, so the round-trip is exact and the test is deterministic. The samples also now land in distinct Decimal32/64/128/256 widths (the random doubles almost always landed in Decimal64). Fixes: https://github.com/ClickHouse/clickhouse-java/issues/2964 --- .../clickhouse/client/datatypes/DataTypesTestingPOJO.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypesTestingPOJO.java b/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypesTestingPOJO.java index 81a92798d..bc8a431d0 100644 --- a/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypesTestingPOJO.java +++ b/client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypesTestingPOJO.java @@ -159,10 +159,10 @@ public DataTypesTestingPOJO() { boxedFloat = random.nextFloat(); boxedDouble = random.nextDouble(); - decimal32 = BigDecimal.valueOf(random.nextDouble()); - decimal64 = BigDecimal.valueOf(random.nextDouble()); - decimal128 = BigDecimal.valueOf(random.nextDouble()); - decimal256 = BigDecimal.valueOf(random.nextDouble()); + decimal32 = new BigDecimal("0.123456789"); + decimal64 = new BigDecimal("0.123456789012345678"); + decimal128 = new BigDecimal("0.12345678901234567890123456789012345678"); + decimal256 = new BigDecimal("0.12345678901234567890123456789012345678901234567890123456789"); bool = random.nextBoolean();