diff --git a/pyiceberg/table/inspect.py b/pyiceberg/table/inspect.py index 5cae743313..4191026cde 100644 --- a/pyiceberg/table/inspect.py +++ b/pyiceberg/table/inspect.py @@ -423,7 +423,7 @@ def _partition_summaries_to_rows( partition_field_type, from_bytes(partition_field_type, field_summary.lower_bound) ) ) - if field_summary.lower_bound + if field_summary.lower_bound is not None else None ) upper_bound = ( @@ -432,7 +432,7 @@ def _partition_summaries_to_rows( partition_field_type, from_bytes(partition_field_type, field_summary.upper_bound) ) ) - if field_summary.upper_bound + if field_summary.upper_bound is not None else None ) rows.append( diff --git a/tests/table/test_inspect.py b/tests/table/test_inspect.py index c325af2033..e612447f24 100644 --- a/tests/table/test_inspect.py +++ b/tests/table/test_inspect.py @@ -21,8 +21,10 @@ import pytest from pyiceberg.conversions import to_bytes +from pyiceberg.partitioning import PartitionField, PartitionSpec from pyiceberg.schema import Schema from pyiceberg.table.inspect import _readable_bound +from pyiceberg.transforms import IdentityTransform from pyiceberg.types import NestedField, StringType from tests.catalog.test_base import InMemoryCatalog @@ -68,3 +70,14 @@ def test_inspect_entries_and_files_render_null_bound(catalog: InMemoryCatalog) - files_metrics = tbl.inspect.files().to_pydict()["readable_metrics"][0]["s"] assert files_metrics["lower_bound"] is None assert files_metrics["upper_bound"] is None + + +def test_inspect_manifests_preserves_empty_string_bounds(catalog: InMemoryCatalog) -> None: + schema = Schema(NestedField(1, "s", StringType(), required=False)) + spec = PartitionSpec(PartitionField(1, 1000, IdentityTransform(), "s")) + tbl = catalog.create_table("default.empty_string_partition", schema, partition_spec=spec) + tbl.append(pa.table({"s": [""]}, schema=pa.schema([pa.field("s", pa.large_string(), nullable=True)]))) + + partition_summary = tbl.inspect.manifests().to_pydict()["partition_summaries"][0][0] + assert partition_summary["lower_bound"] == "" + assert partition_summary["upper_bound"] == ""