public static byte[] fromLogical(Schema schema, BigDecimal value) {
        int schemaScale = scale(schema);
        if (value.scale() != schemaScale)
            throw new DataException(String.format(
                "Decimal value has mismatching scale for given Decimal schema. "
                    + "Schema has scale %d, value has scale %d.",
                schemaScale,
                value.scale()
            ));
        return value.unscaledValue().toByteArray();
    }
Convert a value from its logical format ({@link BigDecimal}) to its encoded format (byte[]).
@param value the logical value
@return the encoded value
connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java