From 28acb07433106db0ab17da9719cd877ae8a6d2ce Mon Sep 17 00:00:00 2001 From: Byunghwa Yun Date: Fri, 23 Sep 2016 15:34:49 +0900 Subject: [PATCH] NIFI-2811 JdbcCommon doesn't convert bigint(20) column. Signed-off-by: Matt Burgess This closes #1053 --- .../nifi/processors/standard/util/JdbcCommon.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JdbcCommon.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JdbcCommon.java index b591d01f21..0aa4c60e37 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JdbcCommon.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JdbcCommon.java @@ -177,8 +177,8 @@ public class JdbcCommon { // long (and the schema says it will be), so try to get its value as a long. // Otherwise, Avro can't handle BigInteger as a number - it will throw an AvroRuntimeException // such as: "Unknown datum type: java.math.BigInteger: 38". In this case the schema is expecting a string. - int precision = meta.getPrecision(i); if (javaSqlType == BIGINT) { + int precision = meta.getPrecision(i); if (precision < 0 || precision > MAX_DIGITS_IN_BIGINT) { rec.put(i - 1, value.toString()); } else { @@ -194,7 +194,16 @@ public class JdbcCommon { } } else if (value instanceof Number || value instanceof Boolean) { - rec.put(i - 1, value); + if (javaSqlType == BIGINT) { + int precision = meta.getPrecision(i); + if (precision < 0 || precision > MAX_DIGITS_IN_BIGINT) { + rec.put(i - 1, value.toString()); + } else { + rec.put(i - 1, value); + } + } else { + rec.put(i - 1, value); + } } else { // The different types that we support are numbers (int, long, double, float),