Skip to content

Commit d44d33c

Browse files
authored
tests: test writing empty file in PyVortex (#4147)
An edge case that is probably useful to have a test for Signed-off-by: Andrew Duffy <[email protected]>
1 parent e5eccef commit d44d33c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vortex-python/test/test_file.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,19 @@ def test_to_arrow_batch_size(vxf):
5353
def test_to_arrow_columns(vxf):
5454
rbr = vxf.to_arrow(projection=["string", "bool"])
5555
assert rbr.schema == pa.schema([("string", pa.string_view()), ("bool", pa.bool_())])
56+
57+
58+
def test_empty_file(tmpdir_factory):
59+
# test for writing empty files with null columns
60+
# create an empty table with schema `empty: null`
61+
table = pa.Table.from_pydict({"empty": []})
62+
assert repr(table.schema) == "empty: null"
63+
64+
# cast to Vortex array
65+
empty = vx.array(table)
66+
assert len(empty) == 0
67+
assert repr(empty.dtype) == 'struct({"empty": null()}, nullable=False)'
68+
69+
# writing file should succeed
70+
empty_file = tmpdir_factory.mktemp("data") / "empty.vortex"
71+
vortex.io.write(empty, str(empty_file))

0 commit comments

Comments
 (0)