@Override
    public DecimalData next() {
        if (nullRate == 0f || ThreadLocalRandom.current().nextFloat() > nullRate) {
            BigDecimal decimal =
                    new BigDecimal(
                            ThreadLocalRandom.current().nextDouble(min, max),
                            new MathContext(precision, RoundingMode.DOWN));
            return DecimalData.fromBigDecimal(decimal, precision, scale);
        }
        return null;
    }
@Test
    void testGenerateDecimalValues() {
        for (int precision = 1; precision <= 38; precision++) {
            for (int scale = 0; scale <= precision; scale++) {
                DecimalDataRandomGenerator gen =
                        new DecimalDataRandomGenerator(
                                precision, scale, Double.MIN_VALUE, Double.MAX_VALUE, 0f);

                DecimalData value = gen.next();
                assertThat(value)
                        .as("Null value for DECIMAL(" + precision + "," + scale + ")")
                        .isNotNull();

                String strRepr = String.valueOf(value);
                if (strRepr.charAt(0) == '-') {
                    // drop the negative sign
                    strRepr = strRepr.substring(1);
                }

                if (scale != precision) {
                    // need to account for decimal . and potential leading zeros
                    assertThat(strRepr)
                            .as(
                                    "Wrong length for DECIMAL("
                                            + precision
                                            + ","
                                            + scale
                                            + ") = "
                                            + strRepr)
                            .hasSizeLessThanOrEqualTo(precision + 1);
                } else {
                    // need to account for decimal . and potential leading zeros
                    assertThat(strRepr)
                            .as(
                                    "Wrong length for DECIMAL("
                                            + precision
                                            + ","
                                            + scale
                                            + ") = "
                                            + strRepr)
                            .hasSizeLessThanOrEqualTo(precision + 2);
                }
                if (scale != 0) {
                    String decimalPart = strRepr.split("\\.")[1];
                    assertThat(decimalPart)
                            .as(
                                    "Wrong length for DECIMAL("
                                            + precision
                                            + ","
                                            + scale
                                            + ") = "
                                            + strRepr)
                            .hasSize(scale);
                }
            }
        }
    }