deniskuzZ commented on code in PR #3438:
URL: https://github.com/apache/hive/pull/3438#discussion_r923419607
##########
serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java:
##########
@@ -115,12 +116,19 @@ public Writable serialize(Object obj, ObjectInspector
objInspector) throws SerDe
final Object field = outputRowOI.getStructFieldData(obj,
outputFieldRefs.get(c));
final ObjectInspector fieldOI =
outputFieldRefs.get(c).getFieldObjectInspector();
- // The data must be of type String
- final StringObjectInspector fieldStringOI = (StringObjectInspector)
fieldOI;
-
// Convert the field to Java class String, because objects of String type
// can be stored in String, Text, or some other classes.
- outputFields[c] = fieldStringOI.getPrimitiveJavaObject(field);
+ if (fieldOI instanceof StringObjectInspector) {
+ outputFields[c] = ((StringObjectInspector)
fieldOI).getPrimitiveJavaObject(field);
+ } else if (fieldOI instanceof AbstractPrimitiveWritableObjectInspector) {
+ final AbstractPrimitiveWritableObjectInspector fieldStringOI =
Review Comment:
could be simplified to:
````
Object primitiveJavaObject =
((PrimitiveObjectInspector)fieldOI).getPrimitiveJavaObject(field);
outputFields[c] = Objects.toString(primitiveJavaObject, null);
````
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]