waitingF commented on code in PR #11637:
URL: https://github.com/apache/hudi/pull/11637#discussion_r1682830022


##########
hudi-common/src/main/java/org/apache/hudi/avro/MercifulJsonConverter.java:
##########
@@ -301,6 +306,14 @@ private static JsonToAvroFieldProcessor 
generateFixedTypeHandler() {
     return new JsonToAvroFieldProcessor() {
       @Override
       public Pair<Boolean, Object> convert(Object value, String name, Schema 
schema, boolean shouldSanitize, String invalidCharMask) {
+        // the value can be Number
+        if (value instanceof Number) {
+          LogicalTypes.Decimal decimalType = (LogicalTypes.Decimal) 
schema.getLogicalType();
+          BigDecimal bigDecimal = new 
java.math.BigDecimal(value.toString()).setScale(decimalType.getScale(), 
RoundingMode.HALF_UP);
+          GenericFixed genericFixed = DECIMAL_CONVERSION.toFixed(bigDecimal, 
schema, schema.getLogicalType());
+          return Pair.of(true, new GenericData.Fixed(schema, 
genericFixed.bytes()));
+        }
+
         // The ObjectMapper use List to represent FixedType
         // eg: "decimal_val": [0, 0, 14, -63, -52] will convert to 
ArrayList<Integer>
         List<Integer> converval = (List<Integer>) value;

Review Comment:
   already added a json example in ut



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