You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by to...@apache.org on 2021/10/08 09:17:30 UTC
[kafka] branch trunk updated: MINOR: Improve decimal scale mismatch
error message in Connect (#11384)
This is an automated email from the ASF dual-hosted git repository.
tombentley pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new a9ffabc MINOR: Improve decimal scale mismatch error message in Connect (#11384)
a9ffabc is described below
commit a9ffabc4470b7847ec394e8e9f993326fd2c3390
Author: Chris Egerton <ch...@confluent.io>
AuthorDate: Fri Oct 8 05:15:37 2021 -0400
MINOR: Improve decimal scale mismatch error message in Connect (#11384)
Use term Decimal, rather than BigDecimal.
Reviewers: Tom Bentley <tb...@redhat.com>
---
.../src/main/java/org/apache/kafka/connect/data/Decimal.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java b/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
index 2bf87f1..a0a8895 100644
--- a/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
+++ b/connect/api/src/main/java/org/apache/kafka/connect/data/Decimal.java
@@ -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();
}