[
https://issues.apache.org/jira/browse/AVRO-1864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ryan Blue resolved AVRO-1864.
-----------------------------
Resolution: Won't Fix
Assignee: Ryan Blue
> Decimal conversion should convert values with scale less than intended scale
> instead of erroring.
> -------------------------------------------------------------------------------------------------
>
> Key: AVRO-1864
> URL: https://issues.apache.org/jira/browse/AVRO-1864
> Project: Avro
> Issue Type: Bug
> Affects Versions: 1.7.6
> Reporter: Thomas Scott
> Assignee: Ryan Blue
> Priority: Minor
>
> Using Sqoop to import data to AVRO can mean that decimal scales in the
> incoming values do not match the scales expected in AVRO. In this situation
> AVRO file creation fails. However, in some cases this is not the correct
> behaviour, given a value of 3.1 and a scale of 3 the value will fit into the
> scale requirements and so should be adjusted.
> Looking through the code this seems to be enforced here:
> src/main/java/org/apache/avro/Conversions.java
> public ByteBuffer toBytes(BigDecimal value, Schema schema, LogicalType type) {
> int scale = ((LogicalTypes.Decimal) type).getScale();
> if (scale != value.scale()) {
> throw new AvroTypeException("Cannot encode decimal with scale " +
> value.scale() + " as scale " + scale);
> Should this not be:
> if (scale < value.scale()) {
> The same applies in: toFixed()
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)