stream2000 commented on code in PR #10756:
URL: https://github.com/apache/hudi/pull/10756#discussion_r1502318964


##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveAvroSerializer.java:
##########
@@ -286,10 +286,14 @@ private Object 
serializePrimitive(PrimitiveObjectInspector fieldOI, Object struc
           throw new HoodieException("Unexpected Avro schema for Binary 
TypeInfo: " + schema.getType());
         }
       case DECIMAL:
-        HiveDecimal dec = 
(HiveDecimal)fieldOI.getPrimitiveJavaObject(structFieldData);
-        LogicalTypes.Decimal decimal = 
(LogicalTypes.Decimal)schema.getLogicalType();
+        HiveDecimal dec = (HiveDecimal) 
fieldOI.getPrimitiveJavaObject(structFieldData);
+        LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) 
schema.getLogicalType();
         BigDecimal bd = new 
BigDecimal(dec.toString()).setScale(decimal.getScale());
-        return HoodieAvroUtils.DECIMAL_CONVERSION.toFixed(bd, schema, decimal);
+        if (schema.getType() == Schema.Type.BYTES) {
+          return HoodieAvroUtils.DECIMAL_CONVERSION.toBytes(bd, schema, 
decimal);
+        } else {
+          return HoodieAvroUtils.DECIMAL_CONVERSION.toFixed(bd, schema, 
decimal);

Review Comment:
   Without this fix, hudi will throw an exception here since bytes decimal 
can't call `toFixed`.



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

Reply via email to