Skip to content

Commit dc66a2f

Browse files
committed
Assert the deletion vector CRC trailer, vector framing and inherited ids
1 parent 09702a4 commit dc66a2f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎tests/table/test_deletion_vector.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ def test_to_blob_metadata() -> None:
229229
# offset and length are placeholders until PuffinWriter assembles the file
230230
assert blob.metadata.offset == 0
231231
assert blob.metadata.length == 0
232+
# -1 marks the snapshot id and sequence number as inherited at commit time, matching Java's
233+
# BaseDVFileWriter.toBlob
234+
assert blob.metadata.snapshot_id == -1
235+
assert blob.metadata.sequence_number == -1
232236

233237

234238
def test_to_blob_payload_layout() -> None:
@@ -242,3 +246,12 @@ def test_to_blob_payload_layout() -> None:
242246
assert length_prefix == len(DELETION_VECTOR_MAGIC) + len(vector)
243247
assert len(blob.payload) == 4 + length_prefix + 4
244248
assert DeletionVector._deserialize_bitmap(vector) == DeletionVector.from_positions("file.parquet", [1, 2, 3])._bitmaps
249+
250+
# The reader tolerates a wrong checksum and wrong magic bytes, so assert the trailer here
251+
# instead of relying on the round-trip above to catch a change in what the CRC covers.
252+
assert int.from_bytes(blob.payload[-4:], "big") == zlib.crc32(DELETION_VECTOR_MAGIC + vector)
253+
254+
# Vector framing: number of non-empty bitmaps (8B little-endian) then the first key (4B
255+
# little-endian). Positions 1..3 share key 0, so exactly one bitmap is written.
256+
assert int.from_bytes(vector[0:8], "little") == 1
257+
assert int.from_bytes(vector[8:12], "little") == 0

0 commit comments

Comments
 (0)