mirror of https://github.com/apache/kafka.git
MINOR: Improve decimal scale mismatch error message in Connect (#11384)
Use term Decimal, rather than BigDecimal. Reviewers: Tom Bentley <tbentley@redhat.com>
This commit is contained in:
parent
3f3a0e0d9e
commit
a9ffabc447
|
@ -64,8 +64,14 @@ public class Decimal {
|
|||
* @return the encoded value
|
||||
*/
|
||||
public static byte[] fromLogical(Schema schema, BigDecimal value) {
|
||||
if (value.scale() != scale(schema))
|
||||
throw new DataException("BigDecimal has mismatching scale value for given Decimal schema");
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue