gideonkorir commented on a change in pull request #3509: NIFI-6295 fix 
deserialization issues with NiFiRecordSerDe for hive3streaming
URL: https://github.com/apache/nifi/pull/3509#discussion_r313978464
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/main/java/org/apache/hive/streaming/NiFiRecordSerDe.java
 ##########
 @@ -187,132 +202,127 @@ private Object extractCurrentField(Record record, 
RecordField field, TypeInfo fi
                 }
                 switch (primitiveCategory) {
                     case BYTE:
-                        Integer bIntValue = record.getAsInt(fieldName);
-                        val = bIntValue == null ? null : bIntValue.byteValue();
+                        Integer bIntValue = 
DataTypeUtils.toInteger(fieldValue, field.getDataType().getFormat());
+                        val = bIntValue.byteValue();
                         break;
                     case SHORT:
-                        Integer sIntValue = record.getAsInt(fieldName);
-                        val = sIntValue == null ? null : 
sIntValue.shortValue();
+                        Integer sIntValue = 
DataTypeUtils.toInteger(fieldValue, field.getDataType().getFormat());
+                        val = sIntValue.shortValue();
                         break;
                     case INT:
-                        val = record.getAsInt(fieldName);
+                        val = DataTypeUtils.toInteger(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case LONG:
-                        val = record.getAsLong(fieldName);
+                        val = DataTypeUtils.toLong(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case BOOLEAN:
-                        val = record.getAsBoolean(fieldName);
+                        val = DataTypeUtils.toBoolean(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case FLOAT:
-                        val = record.getAsFloat(fieldName);
+                        val = DataTypeUtils.toFloat(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case DOUBLE:
-                        val = record.getAsDouble(fieldName);
+                        val = DataTypeUtils.toDouble(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case STRING:
                     case VARCHAR:
                     case CHAR:
-                        val = record.getAsString(fieldName);
+                        val = DataTypeUtils.toString(fieldValue, 
field.getDataType().getFormat());
                         break;
                     case BINARY:
-                        Object[] array = record.getAsArray(fieldName);
-                        if (array == null) {
-                            return null;
-                        }
+                        Object[] array = DataTypeUtils.toArray(fieldValue, 
field.getFieldName(), field.getDataType());
 
 Review comment:
   Thanks will fix that

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to