Skip to content

Commit 4d73212

Browse files
author
redpheonixx
committed
using unscaled_to_decimal from pyiceberg.utils.decimal
1 parent c67849e commit 4d73212

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

pyiceberg/io/pyarrow.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from concurrent.futures import Future
4040
from copy import copy
4141
from dataclasses import dataclass
42-
from decimal import Decimal
4342
from enum import Enum
4443
from functools import lru_cache, singledispatch
4544
from typing import (
@@ -176,6 +175,7 @@
176175
from pyiceberg.utils.concurrent import ExecutorFactory
177176
from pyiceberg.utils.config import Config
178177
from pyiceberg.utils.datetime import millis_to_datetime
178+
from pyiceberg.utils.decimal import unscaled_to_decimal
179179
from pyiceberg.utils.deprecated import deprecation_message
180180
from pyiceberg.utils.properties import get_first_property_value, property_as_bool, property_as_int
181181
from pyiceberg.utils.singleton import Singleton
@@ -2364,15 +2364,9 @@ def data_file_statistics_from_parquet_metadata(
23642364
)
23652365

23662366
if isinstance(stats_col.iceberg_type, DecimalType) and statistics.physical_type != "FIXED_LEN_BYTE_ARRAY":
2367-
precision = stats_col.iceberg_type.precision
23682367
scale = stats_col.iceberg_type.scale
2369-
decimal_type = pa.decimal128(precision, scale)
2370-
col_aggs[field_id].update_min(
2371-
pa.array([Decimal(statistics.min_raw) / (10**scale)], decimal_type)[0].as_py()
2372-
)
2373-
col_aggs[field_id].update_max(
2374-
pa.array([Decimal(statistics.max_raw) / (10**scale)], decimal_type)[0].as_py()
2375-
)
2368+
col_aggs[field_id].update_min(unscaled_to_decimal(statistics.min_raw, scale))
2369+
col_aggs[field_id].update_max(unscaled_to_decimal(statistics.max_raw, scale))
23762370
else:
23772371
col_aggs[field_id].update_min(statistics.min)
23782372
col_aggs[field_id].update_max(statistics.max)

0 commit comments

Comments
 (0)