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



##########
File path: 
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/main/java/org/apache/nifi/util/hive/HiveJdbcCommon.java
##########
@@ -298,14 +318,32 @@ public static Schema createSchema(final ResultSet rs, 
String recordName, boolean
                 // Did not find direct suitable type, need to be clarified!!!!
                 case DECIMAL:
                 case NUMERIC:
-                    
builder.name(columnName).type().unionOf().nullBuilder().endNull().and().stringType().endUnion().noDefault();
+                    if (useLogicalTypes) {
+                        final int precision = 
getPrecision(meta.getPrecision(i));
+                        final int scale = getScale(meta.getScale(i));
+                        
builder.name(columnName).type().unionOf().nullBuilder().endNull().and()
+                                .type(LogicalTypes.decimal(precision, 
scale).addToSchema(Schema.create(Schema.Type.BYTES))).endUnion().noDefault();

Review comment:
       Thanks @exceptionfactory. Avro logical types have well defined Avro 
object formats for example a date is an int type with logicalType date where 
int is the number of days since EPOCH time. For decimal it is either byte or 
fixed type with logicalType decimal and precision and scale must be provided as 
well. 
   {
     "type": "bytes",
     "logicalType": "decimal",
     "precision": 4,
     "scale": 2
   }
   
   So the byte type is coming from the Avro specification:
   https://avro.apache.org/docs/1.8.2/spec.html#Decimal




-- 
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-unsubscr...@nifi.apache.org

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


Reply via email to