Skip to content

Commit 7467c0a

Browse files
committed
PR comments
1 parent ef8e8c9 commit 7467c0a

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

pyiceberg/conversions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _(_: PrimitiveType, b: bytes) -> int:
354354

355355
@from_bytes.register(LongType)
356356
def _(_: PrimitiveType, b: bytes) -> int:
357-
if len(b) == 4:
357+
if len(b) < 8:
358358
# If the length is 4 bytes, it is a promoted IntegerType
359359
return _INT_STRUCT.unpack(b)[0]
360360
return _LONG_STRUCT.unpack(b)[0]
@@ -367,7 +367,7 @@ def _(_: FloatType, b: bytes) -> float:
367367

368368
@from_bytes.register(DoubleType)
369369
def _(_: DoubleType, b: bytes) -> float:
370-
if len(b) == 4:
370+
if len(b) < 8:
371371
# If the length is 4 bytes, it is a promoted FloatType
372372
return _FLOAT_STRUCT.unpack(b)[0]
373373
return _DOUBLE_STRUCT.unpack(b)[0]

tests/expressions/test_evaluator.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ def test_strict_integer_not_in(strict_data_file_schema: Schema, strict_data_file
14841484
(FloatType(), DoubleType(), 30.0, 79.0, LessThan, 50.0, ROWS_MIGHT_MATCH),
14851485
],
14861486
)
1487-
def test_inclusive_metrics_evaluator_with_type_promotion(
1487+
def test_inclusive_metrics_eval_bounds_after_promotion(
14881488
file_type: PrimitiveType,
14891489
evolved_type: PrimitiveType,
14901490
lower_bound: Any,
@@ -1493,10 +1493,8 @@ def test_inclusive_metrics_evaluator_with_type_promotion(
14931493
lit: Any,
14941494
expected: bool,
14951495
) -> None:
1496-
# Schema defines 'col' with evolved state
14971496
schema = Schema(NestedField(1, "col", evolved_type, required=True))
14981497

1499-
# Historical manifest contains file_type bounds
15001498
data_file = DataFile.from_args(
15011499
file_path="file_1.parquet",
15021500
file_format=FileFormat.PARQUET,
@@ -1507,7 +1505,6 @@ def test_inclusive_metrics_evaluator_with_type_promotion(
15071505
upper_bounds={1: to_bytes(file_type, upper_bound)},
15081506
)
15091507

1510-
# Predicate refers to 'col'
15111508
evaluator = _InclusiveMetricsEvaluator(schema, op("col", lit))
15121509
assert evaluator.eval(data_file) == expected
15131510

@@ -1527,7 +1524,7 @@ def test_inclusive_metrics_evaluator_with_type_promotion(
15271524
(FloatType(), DoubleType(), 30.0, 79.0, LessThan, 20.0, ROWS_MIGHT_NOT_MATCH),
15281525
],
15291526
)
1530-
def test_strict_metrics_evaluator_with_type_promotion(
1527+
def test_strict_metrics_eval_bounds_after_promotion(
15311528
file_type: PrimitiveType,
15321529
evolved_type: PrimitiveType,
15331530
lower_bound: Any,
@@ -1536,10 +1533,8 @@ def test_strict_metrics_evaluator_with_type_promotion(
15361533
lit: Any,
15371534
expected: bool,
15381535
) -> None:
1539-
# Schema defines 'col' with evolved state
15401536
schema = Schema(NestedField(1, "col", evolved_type, required=True))
15411537

1542-
# Historical manifest contains file_type bounds
15431538
data_file = DataFile.from_args(
15441539
file_path="file_1.parquet",
15451540
file_format=FileFormat.PARQUET,
@@ -1552,6 +1547,5 @@ def test_strict_metrics_evaluator_with_type_promotion(
15521547
nan_value_counts={1: 0},
15531548
)
15541549

1555-
# Predicate refers to 'col'
15561550
evaluator = _StrictMetricsEvaluator(schema, op("col", lit))
15571551
assert evaluator.eval(data_file) == expected

0 commit comments

Comments
 (0)