This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-mosaic.git


The following commit(s) were added to refs/heads/main by this push:
     new 09908ca  fix: preserve empty projection in read_table (#25)
09908ca is described below

commit 09908ca29c0da12e553d55d6cd7688be9c682505
Author: QuakeWang <[email protected]>
AuthorDate: Thu May 21 12:52:58 2026 +0800

    fix: preserve empty projection in read_table (#25)
---
 python/mosaic/mosaic.py     |  2 +-
 python/tests/test_mosaic.py | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/python/mosaic/mosaic.py b/python/mosaic/mosaic.py
index ab759de..91c62ac 100644
--- a/python/mosaic/mosaic.py
+++ b/python/mosaic/mosaic.py
@@ -411,6 +411,6 @@ def write_table(table, stream, options=None):
 
 def read_table(read_at_fn, file_length, columns=None):
     with MosaicReader.from_input_file(read_at_fn, file_length) as reader:
-        if columns:
+        if columns is not None:
             reader.project(columns)
         return reader.read_all()
diff --git a/python/tests/test_mosaic.py b/python/tests/test_mosaic.py
index b60f0f1..a333ea4 100644
--- a/python/tests/test_mosaic.py
+++ b/python/tests/test_mosaic.py
@@ -657,6 +657,28 @@ class TestConvenience:
         assert result.column("id").to_pylist() == list(range(30))
         assert result.column("name").to_pylist() == [f"user_{i}" for i in 
range(30)]
 
+    def test_read_table_empty_projection(self):
+        table = pa.table(
+            {
+                "id": pa.array(list(range(30)), type=pa.int32()),
+                "name": pa.array([f"user_{i}" for i in range(30)]),
+            }
+        )
+
+        buf = io.BytesIO()
+        write_table(table, buf)
+
+        data = buf.getvalue()
+        result = read_table(
+            lambda offset, length: data[offset : offset + length],
+            len(data),
+            columns=[],
+        )
+
+        assert result.num_columns == 0
+        assert result.num_rows == 30
+        assert result.schema.names == []
+
     def test_read_all(self):
         pa_schema = pa.schema(
             [pa.field("x", pa.int32()), pa.field("y", pa.utf8())]

Reply via email to