Skip to content

Commit 246105d

Browse files
timsaucerclaude
andcommitted
Add pathlib.Path and empty batch tests for Arrow IPC and register_batch
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e494bed commit 246105d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/tests/test_context.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ def test_read_arrow(ctx, tmp_path):
680680
assert result[0].column(0) == pa.array([1, 2, 3])
681681
assert result[0].column(1) == pa.array(["x", "y", "z"])
682682

683+
# Also verify pathlib.Path works
684+
df = ctx.read_arrow(arrow_path)
685+
result = df.collect()
686+
assert result[0].column(0) == pa.array([1, 2, 3])
687+
683688

684689
def test_read_empty(ctx):
685690
df = ctx.read_empty()
@@ -698,6 +703,11 @@ def test_register_arrow(ctx, tmp_path):
698703
result = ctx.sql("SELECT * FROM arrow_tbl").collect()
699704
assert result[0].column(0) == pa.array([10, 20, 30])
700705

706+
# Also verify pathlib.Path works
707+
ctx.register_arrow("arrow_tbl_path", arrow_path)
708+
result = ctx.sql("SELECT * FROM arrow_tbl_path").collect()
709+
assert result[0].column(0) == pa.array([10, 20, 30])
710+
701711

702712
def test_register_batch(ctx):
703713
batch = pa.RecordBatch.from_pydict({"a": [1, 2, 3], "b": [4, 5, 6]})
@@ -707,6 +717,13 @@ def test_register_batch(ctx):
707717
assert result[0].column(1) == pa.array([4, 5, 6])
708718

709719

720+
def test_register_batch_empty(ctx):
721+
batch = pa.RecordBatch.from_pydict({"a": pa.array([], type=pa.int64())})
722+
ctx.register_batch("empty_batch_tbl", batch)
723+
result = ctx.sql("SELECT * FROM empty_batch_tbl").collect()
724+
assert result[0].num_rows == 0
725+
726+
710727
def test_create_sql_options():
711728
SQLOptions()
712729

0 commit comments

Comments
 (0)