public static boolean checkLiteralOverflowInDecimalStyle(BigDecimal value, ScalarType scalarType) {
        int realPrecision = getRealPrecision(value);
        int realScale = getRealScale(value);
        BigInteger underlyingInt = value.setScale(scalarType.getScalarScale(), RoundingMode.HALF_UP).unscaledValue();
        BigInteger maxDecimal = BigInteger.TEN.pow(scalarType.decimalPrecision());
        BigInteger minDecimal = BigInteger.TEN.pow(scalarType.decimalPrecision()).negate();

        if (underlyingInt.compareTo(minDecimal) <= 0 || underlyingInt.compareTo(maxDecimal) >= 0) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Typed decimal literal({}) is overflow, value='{}' (precision={}, scale={})",
                        scalarType, value.toPlainString(), realPrecision, realScale);
            }
            return false;
        }
        return true;
    }
@Test
    public void testCheckLiteralOverflowInDecimalStyleFail() throws AnalysisException {
        BigDecimal decimal32Values[] = {
                new BigDecimal("100000.0000"),
                new BigDecimal("99999.99995"),
                new BigDecimal("-100000.0000"),
                new BigDecimal("-99999.99995"),
        };
        ScalarType decimal32p9s4 = ScalarType.createDecimalV3Type(PrimitiveType.DECIMAL32, 9, 4);
        for (BigDecimal dec32 : decimal32Values) {
            Assert.assertFalse(DecimalLiteral.checkLiteralOverflowInDecimalStyle(dec32, decimal32p9s4));
        }

        BigDecimal decimal64Values[] = {
                new BigDecimal("1000000000000.000000"),
                new BigDecimal("999999999999.9999995"),
                new BigDecimal("-1000000000000.000000"),
                new BigDecimal("-999999999999.9999995"),
        };
        ScalarType decimal64p18s6 = ScalarType.createDecimalV3Type(PrimitiveType.DECIMAL64, 18, 6);
        for (BigDecimal dec64 : decimal64Values) {
            Assert.assertFalse(DecimalLiteral.checkLiteralOverflowInDecimalStyle(dec64, decimal64p18s6));
        }

        BigDecimal decimal128Values[] = {
                new BigDecimal("1000000000000000000000000000.00000000000"),
                new BigDecimal("999999999999999999999999999.999999999995"),
                new BigDecimal("-1000000000000000000000000000.00000000000"),
                new BigDecimal("-999999999999999999999999999.999999999995"),
        };
        ScalarType decimal128p38s11 = ScalarType.createDecimalV3Type(PrimitiveType.DECIMAL128, 38, 11);
        for (BigDecimal dec128 : decimal128Values) {
            Assert.assertFalse(DecimalLiteral.checkLiteralOverflowInDecimalStyle(dec128, decimal128p38s11));
        }
    }