You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/07/19 08:38:10 UTC

[GitHub] [hive] ayushtkn commented on a diff in pull request #3438: HIVE-26388: ClassCastException when there is non string type column in source table of CTAS query.

ayushtkn commented on code in PR #3438:
URL: https://github.com/apache/hive/pull/3438#discussion_r924221303


##########
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:
   Do you intend to change to ``PrimitiveObjectInspector`` from ``AbstractPrimitiveWritableObjectInspector``. I am not sure if we can do that PrimitiveObjectInspector has couple of child class which doesn’t implement toString like JavaByteObjectInspector?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org