Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2687#discussion_r214790148
--- Diff:
store/sdk/src/main/java/org/apache/carbondata/sdk/file/AvroCarbonWriter.java ---
@@ -407,6 +413,19 @@ private Object avroFieldToObjectForUnionType(Schema
avroField, Object fieldValue
out = null;
}
break;
+ case BYTES:
+ // DECIMAL type is defined in Avro as a BYTE type with the
logicalType property
+ // set to "decimal" and a specified precision and scale
+ // As binary type is not supported yet,value will be null
+ if (logicalType instanceof LogicalTypes.Decimal) {
+ BigDecimal decimalValue = new BigDecimal(new
String(((ByteBuffer) fieldValue).array(),
+ CarbonCommonConstants.DEFAULT_CHARSET_CLASS));
+ out = (decimalValue.round(
+ new MathContext(((LogicalTypes.Decimal)
avroField.getLogicalType()).getPrecision())))
+ .setScale(((LogicalTypes.Decimal)
avroField.getLogicalType()).getScale(),
+ RoundingMode.HALF_UP);
--- End diff --
replace bigdecimal conversion with below code at all places in the code
`BigDecimal bigDecimal = new BigDecimal(new String(((ByteBuffer)
fieldValue).array(), CarbonCommonConstants.DEFAULT_CHARSET_CLASS)
.setScale(dimension.getColumnSchema().getScale(),
RoundingMode.HALF_UP);`
---