Skip to content

Commit efb2848

Browse files
committed
Match the sign of zero with a single comparison
1 parent 798bb46 commit efb2848

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎pyiceberg/io/pyarrow.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,9 +3220,8 @@ def _partition_value_filter(partition_field_name: str, value: Any) -> pc.Express
32203220
return pc.is_nan(pc.field(partition_field_name))
32213221
elif isinstance(value, float) and value == 0.0:
32223222
# -0.0 and 0.0 are separate partitions but compare equal, so also match the sign (1 / -0.0 is -inf)
3223-
negative_sign = pc.divide(pc.scalar(1.0), pc.field(partition_field_name)) < 0
3224-
same_sign = negative_sign if math.copysign(1.0, value) < 0 else ~negative_sign
3225-
return (pc.field(partition_field_name) == value) & same_sign
3223+
field = pc.field(partition_field_name)
3224+
return (field == value) & (pc.divide(pc.scalar(1.0), field) == math.copysign(math.inf, value))
32263225
return pc.field(partition_field_name) == value
32273226

32283227

0 commit comments

Comments
 (0)