thomasrebele commented on code in PR #6900:
URL: https://github.com/apache/hive/pull/6900#discussion_r4326706958


##########
serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java:
##########
@@ -131,6 +132,10 @@ public Writable doSerialize(Object obj, ObjectInspector 
objInspector) throws Ser
       } else if (fieldOI instanceof AbstractPrimitiveWritableObjectInspector) {
         Object primitiveJavaObject = 
((AbstractPrimitiveWritableObjectInspector) 
fieldOI).getPrimitiveJavaObject(field);
         outputFields[c] = Objects.toString(primitiveJavaObject, null);
+      } else if (fieldOI instanceof AbstractPrimitiveLazyObjectInspector) {
+        Object primitiveJavaObject =
+            ((AbstractPrimitiveLazyObjectInspector<?>) 
fieldOI).getPrimitiveWritableObject(field);
+        outputFields[c] = Objects.toString(primitiveJavaObject, null);
       } else {

Review Comment:
   There was a 
[discussion](https://github.com/apache/hive/pull/3438#pullrequestreview-1041921124)
 around these questions on the PR that introduced these lines. Unfortunately 
part of the discussion are not available.
   
   From what I understood: calling getPrimitiveJavaObject might return, e.g., 
byte[], and calling toString method on that object would results in a value 
like "[B@6acbcfc0", which is not the goal of the OpenCSVSerde. The patch of 
HIVE-26388 specifically uses AbstractPrimitiveWritableObjectInspector as the 
getPrimitiveWritableObject returns an object that outputs a reasonable String 
when calling toString.
   
   I suggest extending this approach to AbstractPrimitiveLazyObjectInspector, 
which also provides a getPrimitiveWritableObject function. I checked the code 
of the implementations, and they return the same objects as the 
AbstractPrimitiveWritableObjectInspector.



-- 
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]

Reply via email to