redpheonixx commented on code in PR #1799:
URL: https://github.com/apache/iceberg-python/pull/1799#discussion_r2001296080
##########
pyiceberg/io/pyarrow.py:
##########
@@ -2335,9 +2340,18 @@ def data_file_statistics_from_parquet_metadata(
col_aggs[field_id] = StatsAggregator(
stats_col.iceberg_type, statistics.physical_type,
stats_col.mode.length
)
-
- col_aggs[field_id].update_min(statistics.min)
- col_aggs[field_id].update_max(statistics.max)
+ matches=DECIMAL_REGEX.search(str(stats_col.iceberg_type))
+ if matches and statistics.physical_type !=
"FIXED_LEN_BYTE_ARRAY":
+ precision=int(matches.group(1))
+ scale=int(matches.group(2))
+ local_context = Context(prec=precision)
+ decoded_min =
local_context.create_decimal(Decimal(statistics.min_raw)/ (10 ** scale))
+ decoded_max =
local_context.create_decimal(Decimal(statistics.max_raw)/ (10 ** scale))
+ col_aggs[field_id].update_min(decoded_min)
+ col_aggs[field_id].update_max(decoded_max)
+ else:
+ col_aggs[field_id].update_min(statistics.min)
+ col_aggs[field_id].update_max(statistics.max)
Review Comment:
I have updated above as below
```
if isinstance(stats_col.iceberg_type, DecimalType) and
statistics.physical_type != "FIXED_LEN_BYTE_ARRAY":
precision= stats_col.iceberg_type.precision
scale = stats_col.iceberg_type.scale
decimal_type = pa.decimal128(precision, scale)
col_aggs[field_id].update_min(pa.array([Decimal(statistics.min_raw)/ (10 **
scale)], decimal_type)[0].as_py())
col_aggs[field_id].update_max(pa.array([Decimal(statistics.max_raw)/ (10 **
scale)], decimal_type)[0].as_py())
else:
col_aggs[field_id].update_min(statistics.min)
col_aggs[field_id].update_max(statistics.max)
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]