You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/09/01 15:48:14 UTC

[GitHub] [nifi] mattyb149 commented on a change in pull request #5358: NIFI-9185 dd Avro logical type to SelectHive3QL processor

mattyb149 commented on a change in pull request #5358:
URL: https://github.com/apache/nifi/pull/5358#discussion_r700342403



##########
File path: nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/main/java/org/apache/nifi/util/hive/HiveJdbcCommon.java
##########
@@ -149,7 +155,16 @@ public static long convertToAvroStream(final ResultSet rs, final OutputStream ou
                         // org.apache.avro.AvroRuntimeException: Unknown datum type java.lang.Byte
                         rec.put(i - 1, ((Byte) value).intValue());
 
-                    } else if (value instanceof BigDecimal || value instanceof BigInteger) {
+                    } else if (value instanceof BigDecimal) {
+                        if (useLogicalTypes) {
+                            final int precision = meta.getPrecision(i) > 1 ? meta.getPrecision(i) : 10;
+                            final int scale = meta.getScale(i) > 0 ? meta.getScale(i) : 0;
+                            rec.put(i - 1, AvroTypeUtil.convertToAvroObject(value, LogicalTypes.decimal(precision, scale).addToSchema(Schema.create(Schema.Type.BYTES))));
+                        } else {
+                            rec.put(i - 1, value.toString());
+                        }
+
+                    } else if (value instanceof BigInteger) {

Review comment:
       JdbcCommon offers support for BigInteger in Avro under certain circumstances, we should include those here. In general I would check HiveJdbcCommon (in the nifi-hive3-processors module) against JdbcCommon and make sure we're doing conversions and such the exact same way if possible.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org