Fokko commented on code in PR #2306:
URL: https://github.com/apache/iceberg-python/pull/2306#discussion_r2269718181


##########
pyiceberg/io/pyarrow.py:
##########
@@ -2445,8 +2445,12 @@ def data_file_statistics_from_parquet_metadata(
 
                     if isinstance(stats_col.iceberg_type, DecimalType) and 
statistics.physical_type != "FIXED_LEN_BYTE_ARRAY":
                         scale = stats_col.iceberg_type.scale
-                        
col_aggs[field_id].update_min(unscaled_to_decimal(statistics.min_raw, scale))
-                        
col_aggs[field_id].update_max(unscaled_to_decimal(statistics.max_raw, scale))
+                        col_aggs[field_id].update_min(
+                            unscaled_to_decimal(statistics.min_raw, scale)
+                        ) if statistics.min_raw else None

Review Comment:
   I believe we want to check explicitly for `None`, otherwise it will also 
match for `0`:
   
   ```
   >>> True if 0 else False
   False
   ```
   
   ```suggestion
                           ) if statistics.min_raw is not None else None
   ```



##########
pyiceberg/io/pyarrow.py:
##########
@@ -2445,8 +2445,12 @@ def data_file_statistics_from_parquet_metadata(
 
                     if isinstance(stats_col.iceberg_type, DecimalType) and 
statistics.physical_type != "FIXED_LEN_BYTE_ARRAY":
                         scale = stats_col.iceberg_type.scale
-                        
col_aggs[field_id].update_min(unscaled_to_decimal(statistics.min_raw, scale))
-                        
col_aggs[field_id].update_max(unscaled_to_decimal(statistics.max_raw, scale))
+                        col_aggs[field_id].update_min(
+                            unscaled_to_decimal(statistics.min_raw, scale)
+                        ) if statistics.min_raw else None
+                        col_aggs[field_id].update_max(
+                            unscaled_to_decimal(statistics.max_raw, scale)
+                        ) if statistics.max_raw else None

Review Comment:
   ```suggestion
                           ) if statistics.max_raw is not None else None
   ```



##########
tests/io/test_pyarrow_stats.py:
##########
@@ -450,6 +450,9 @@ def construct_test_table_primitive_types() -> 
Tuple[pq.FileMetaData, Union[Table
                     {"id": 13, "name": "decimal8", "required": False, "type": 
"decimal(5, 2)"},
                     {"id": 14, "name": "decimal16", "required": False, "type": 
"decimal(16, 6)"},
                     {"id": 15, "name": "decimal32", "required": False, "type": 
"decimal(19, 6)"},
+                    {"id": 16, "name": "empty_decimal8", "required": False, 
"type": "decimal(5, 2)"},
+                    {"id": 17, "name": "empty_decimal16", "required": False, 
"type": "decimal(16, 6)"},
+                    {"id": 18, "name": "empty_decimal32", "required": False, 
"type": "decimal(19, 6)"},

Review Comment:
   I think that's the case: 
https://github.com/apache/iceberg-python/commit/1a5e32ab234ed180b4a2dadb4e8399de4a39ab2f#diff-a233ed42334b1688676cb1d7dca85c5f53fb5d52ece97e33f8f366b007a6994dR450-R452



-- 
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]

Reply via email to