Skip to content

Commit

Permalink
fixed the bug, string should convert to utf8 for avro record
Browse files Browse the repository at this point in the history
  • Loading branch information
xiarixiaoyao committed Oct 19, 2022
1 parent 3bc9f04 commit db4f1da
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.avro.generic.GenericEnumSymbol;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.specific.SpecificRecordBase;
import org.apache.avro.util.Utf8;
import org.apache.hadoop.hive.common.type.HiveChar;
import org.apache.hadoop.hive.common.type.HiveDecimal;
import org.apache.hadoop.hive.common.type.HiveVarchar;
Expand Down Expand Up @@ -289,10 +290,10 @@ private Object serializePrimitive(PrimitiveObjectInspector fieldOI, Object struc
return HoodieAvroUtils.DECIMAL_CONVERSION.toFixed(bd, schema, decimal);
case CHAR:
HiveChar ch = (HiveChar)fieldOI.getPrimitiveJavaObject(structFieldData);
return ch.getStrippedValue();
return new Utf8(ch.getStrippedValue());
case VARCHAR:
HiveVarchar vc = (HiveVarchar)fieldOI.getPrimitiveJavaObject(structFieldData);
return vc.getValue();
return new Utf8(vc.getValue());
case DATE:
return DateWritable.dateToDays(((DateObjectInspector)fieldOI).getPrimitiveJavaObject(structFieldData));
case TIMESTAMP:
Expand Down

0 comments on commit db4f1da

Please sign in to comment.