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:
Chris Egerton 2021-10-08 05:15:37 -04:00 committed by GitHub
parent 3f3a0e0d9e
commit a9ffabc447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -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();
}