diff --git a/dev/provision.py b/dev/provision.py index 6c8fe366d7..53360748b6 100644 --- a/dev/provision.py +++ b/dev/provision.py @@ -389,3 +389,13 @@ VALUES (4) """ ) + + spark.sql( + f""" + CREATE OR REPLACE TABLE {catalog_name}.default.test_empty_scan_ordered_str (id string NOT NULL) + USING iceberg + TBLPROPERTIES ('format-version'='2') + """ + ) + spark.sql(f"ALTER TABLE {catalog_name}.default.test_empty_scan_ordered_str WRITE ORDERED BY id") + spark.sql(f"INSERT INTO {catalog_name}.default.test_empty_scan_ordered_str VALUES 'a', 'c'") diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py index 4175f5fecf..aefe86ac7a 100644 --- a/pyiceberg/io/pyarrow.py +++ b/pyiceberg/io/pyarrow.py @@ -1589,7 +1589,7 @@ def schema_partner(self, partner: Optional[pa.Array]) -> Optional[pa.Array]: return partner def field_partner(self, partner_struct: Optional[pa.Array], field_id: int, _: str) -> Optional[pa.Array]: - if partner_struct: + if partner_struct is not None: # use the field name from the file schema try: name = self.file_schema.find_field(field_id).name diff --git a/tests/integration/test_reads.py b/tests/integration/test_reads.py index 078abf406a..078ec163d4 100644 --- a/tests/integration/test_reads.py +++ b/tests/integration/test_reads.py @@ -663,3 +663,11 @@ def another_task() -> None: table.transaction().set_properties(lock="xxx").commit_transaction() assert table.properties.get("lock") == "xxx" + + +@pytest.mark.integration +@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) +def test_empty_scan_ordered_str(catalog: Catalog) -> None: + table_empty_scan_ordered_str = catalog.load_table("default.test_empty_scan_ordered_str") + arrow_table = table_empty_scan_ordered_str.scan(EqualTo("id", "b")).to_arrow() + assert len(arrow_table) == 0