openinx commented on a change in pull request #1271:
URL: https://github.com/apache/iceberg/pull/1271#discussion_r464849520
##########
File path:
spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcValueReaders.java
##########
@@ -195,7 +196,12 @@ public Long nonNullRead(ColumnVector vector, int row) {
@Override
public Decimal nonNullRead(ColumnVector vector, int row) {
HiveDecimalWritable value = ((DecimalColumnVector) vector).vector[row];
- return new Decimal().set(value.serialize64(value.scale()),
value.precision(), value.scale());
+ BigDecimal decimal = new
BigDecimal(BigInteger.valueOf(value.serialize64(value.scale())), value.scale());
Review comment:
Oh, seems it's still incorrect. Because the `value.serialize64(scale)`
is still encoded by `value.precision()` and `value.scale()`. we use the given
`precision` and `scale` to parse this long value, it will be messed up.
Notice, the value.precision is not equals to `precision`, similar to scale.
The correct way should be:
```java
Decimal decimal = new Decimal().set(value.serialize64(value.scale()),
value.precision(), value.scale());
decimal.changePrecision(precision, scale);
```
----------------------------------------------------------------
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]