|
27 | 27 | import pyiceberg.manifest as manifest_module |
28 | 28 | from pyiceberg.avro.codecs import AvroCompressionCodec |
29 | 29 | from pyiceberg.avro.file import DEFAULT_SYNC_INTERVAL, AvroFile, AvroOutputFile |
| 30 | +from pyiceberg.conversions import to_bytes |
30 | 31 | from pyiceberg.encryption.key_metadata import StandardKeyMetadata |
31 | 32 | from pyiceberg.encryption.manager import EncryptionManager |
32 | 33 | from pyiceberg.encryption.stream import _encrypt_ags1 |
|
47 | 48 | _inherit_from_manifest, |
48 | 49 | _manifests, |
49 | 50 | clear_manifest_cache, |
| 51 | + construct_partition_summaries, |
50 | 52 | read_manifest_list, |
51 | 53 | write_manifest, |
52 | 54 | write_manifest_list, |
53 | 55 | ) |
54 | | -from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec |
| 56 | +from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionField, PartitionSpec |
55 | 57 | from pyiceberg.schema import Schema |
56 | 58 | from pyiceberg.table.snapshots import Operation, Snapshot, Summary |
| 59 | +from pyiceberg.transforms import IdentityTransform |
57 | 60 | from pyiceberg.typedef import Record, TableVersion |
58 | | -from pyiceberg.types import IntegerType, ListType, LongType, NestedField, StructType |
| 61 | +from pyiceberg.types import DoubleType, FloatType, IntegerType, ListType, LongType, NestedField, StructType |
59 | 62 | from tests.encryption.memory_kms import MemoryKeyManagementClient |
60 | 63 |
|
61 | 64 |
|
@@ -1365,6 +1368,21 @@ def test_write_manifest_min_sequence_number_zero(format_version: TableVersion) - |
1365 | 1368 | assert manifest_file.min_sequence_number == 0 |
1366 | 1369 |
|
1367 | 1370 |
|
| 1371 | +def test_construct_partition_summaries_orders_negative_zero_below_zero() -> None: |
| 1372 | + spec = PartitionSpec(PartitionField(source_id=1, field_id=1000, transform=IdentityTransform(), name="x")) |
| 1373 | + for field_type in (FloatType(), DoubleType()): |
| 1374 | + schema = Schema(NestedField(1, "x", field_type, required=False)) |
| 1375 | + expected = PartitionFieldSummary.from_args( |
| 1376 | + contains_null=False, |
| 1377 | + contains_nan=False, |
| 1378 | + lower_bound=to_bytes(field_type, -0.0), |
| 1379 | + upper_bound=to_bytes(field_type, 0.0), |
| 1380 | + ) |
| 1381 | + for values in ([0.0, -0.0], [-0.0, 0.0]): |
| 1382 | + summaries = construct_partition_summaries(spec, schema, [Record(value) for value in values]) |
| 1383 | + assert summaries == [expected], (field_type, values) |
| 1384 | + |
| 1385 | + |
1368 | 1386 | def test_inherit_from_manifest_snapshot_id() -> None: |
1369 | 1387 | entry = ManifestEntry.from_args( |
1370 | 1388 | status=ManifestEntryStatus.ADDED, |
|
0 commit comments