Fokko commented on a change in pull request #1648:
URL: https://github.com/apache/iceberg/pull/1648#discussion_r592235285
##########
File path: parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvro.java
##########
@@ -169,12 +164,14 @@ public String getLogicalTypeName() {
@Override
public BigDecimal fromFixed(GenericFixed value, Schema schema, LogicalType
type) {
- return super.fromFixed(value, schema, decimalsByScale[((ParquetDecimal)
type).scale()]);
+ final ParquetDecimal dec = (ParquetDecimal) type;
+ return super.fromFixed(value, schema,
LogicalTypes.decimal(dec.precision(), dec.scale()));
Review comment:
I know, but we didn't take the scale into account, so it could actually
change the scale. I fixed this in the `fromFixed` by directly creating the
`BigDecimal`, this is what's happening in the Avro library:
```
@Override
public BigDecimal fromFixed(GenericFixed value, Schema schema,
LogicalType type) {
int scale = ((LogicalTypes.Decimal) type).getScale();
return new BigDecimal(new BigInteger(value.bytes()), scale);
}
```
For the `toFixed` this isn't that trivial, since this would mean copying a
lot of code.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]