Matrix42 commented on a change in pull request #3837:
URL: https://github.com/apache/hudi/pull/3837#discussion_r733358285
##########
File path: hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
##########
@@ -546,8 +546,11 @@ private static Object
convertValueForAvroLogicalTypes(Schema fieldSchema, Object
return decimalConversion.fromFixed((GenericFixed) fieldValue,
fieldSchema,
LogicalTypes.decimal(dc.getPrecision(), dc.getScale()));
} else if (fieldSchema.getType() == Schema.Type.BYTES) {
- return decimalConversion.fromBytes((ByteBuffer) fieldValue,
fieldSchema,
- LogicalTypes.decimal(dc.getPrecision(), dc.getScale()));
+ ByteBuffer byteBuffer = (ByteBuffer) fieldValue;
+ BigDecimal convertedValue = decimalConversion.fromBytes((ByteBuffer)
fieldValue, fieldSchema,
Review comment:
done
##########
File path:
hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java
##########
@@ -240,4 +247,22 @@ public void testGetNestedFieldVal() {
}
}
+ @Test
+ public void testGetNestedFieldValWithDecimalFiled() {
+ GenericRecord rec = new GenericData.Record(new
Schema.Parser().parse(SCHEMA_WITH_DECIMAL_FIELD));
+ rec.put("key_col", "key");
+ BigDecimal bigDecimal = new BigDecimal("1234.5678");
+ ByteBuffer byteBuffer =
ByteBuffer.wrap(bigDecimal.unscaledValue().toByteArray());
+ rec.put("decimal_col", byteBuffer);
+
+
Review comment:
done
--
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]