Skip to content

Commit fc1f6dd

Browse files
committed
refactor StatsAggregator to require column_name as a non-optional parameter
1 parent 02bf9fb commit fc1f6dd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pyiceberg/io/pyarrow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,14 +1981,14 @@ def visit_unknown(self, unknown_type: UnknownType) -> str:
19811981
class StatsAggregator:
19821982
current_min: Any
19831983
current_max: Any
1984+
column_name: str
19841985
trunc_length: Optional[int]
1985-
column_name: Optional[str]
19861986

1987-
def __init__(self, iceberg_type: PrimitiveType, physical_type_string: str, trunc_length: Optional[int] = None, column_name: Optional[str] = None) -> None:
1987+
def __init__(self, iceberg_type: PrimitiveType, physical_type_string: str, column_name: str, trunc_length: Optional[int] = None) -> None:
19881988
self.current_min = None
19891989
self.current_max = None
1990-
self.trunc_length = trunc_length
19911990
self.column_name = column_name
1991+
self.trunc_length = trunc_length
19921992

19931993
expected_physical_type = _primitive_to_physical(iceberg_type)
19941994
if expected_physical_type != physical_type_string:
@@ -2000,7 +2000,7 @@ def __init__(self, iceberg_type: PrimitiveType, physical_type_string: str, trunc
20002000
pass
20012001
else:
20022002
raise ValueError(
2003-
f"Unexpected physical type {physical_type_string} for {self.column_name or '<unknown column>'} with iceberg type {iceberg_type}, expected {expected_physical_type}"
2003+
f"Unexpected physical type {physical_type_string} for {self.column_name} with iceberg type {iceberg_type}, expected {expected_physical_type}"
20042004
)
20052005

20062006
self.primitive_type = iceberg_type
@@ -2407,7 +2407,7 @@ def data_file_statistics_from_parquet_metadata(
24072407

24082408
if field_id not in col_aggs:
24092409
col_aggs[field_id] = StatsAggregator(
2410-
stats_col.iceberg_type, statistics.physical_type, stats_col.mode.length, stats_col.column_name
2410+
stats_col.iceberg_type, statistics.physical_type, stats_col.column_name, stats_col.mode.length
24112411
)
24122412

24132413
if isinstance(stats_col.iceberg_type, DecimalType) and statistics.physical_type != "FIXED_LEN_BYTE_ARRAY":

0 commit comments

Comments
 (0)