Skip to content

Commit da6001b

Browse files
committed
Core: Preserve empty bounds in inspect.manifests
1 parent 68898e5 commit da6001b

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

pyiceberg/table/inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def _partition_summaries_to_rows(
560560
partition_field_type, from_bytes(partition_field_type, field_summary.lower_bound)
561561
)
562562
)
563-
if field_summary.lower_bound
563+
if field_summary.lower_bound is not None
564564
else None
565565
)
566566
upper_bound = (
@@ -569,7 +569,7 @@ def _partition_summaries_to_rows(
569569
partition_field_type, from_bytes(partition_field_type, field_summary.upper_bound)
570570
)
571571
)
572-
if field_summary.upper_bound
572+
if field_summary.upper_bound is not None
573573
else None
574574
)
575575
rows.append(

tests/table/test_inspect.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323

2424
from pyiceberg.conversions import to_bytes
2525
from pyiceberg.manifest import DataFile, DataFileContent
26+
from pyiceberg.partitioning import PartitionField, PartitionSpec
2627
from pyiceberg.schema import Schema
2728
from pyiceberg.table.inspect import InspectTable, _readable_bound
2829
from pyiceberg.table.snapshots import Snapshot
30+
from pyiceberg.transforms import IdentityTransform
2931
from pyiceberg.typedef import Record
3032
from pyiceberg.types import NestedField, StringType
3133
from tests.catalog.test_base import InMemoryCatalog
@@ -93,3 +95,14 @@ def test_partitions_last_updated_uses_latest_snapshot_regardless_of_order(newest
9395
(partition_row,) = partitions_map.values()
9496
assert partition_row["last_updated_at"] == newer.timestamp_ms
9597
assert partition_row["last_updated_snapshot_id"] == newer.snapshot_id
98+
99+
100+
def test_inspect_manifests_preserves_empty_string_bounds(catalog: InMemoryCatalog) -> None:
101+
schema = Schema(NestedField(1, "s", StringType()))
102+
spec = PartitionSpec(PartitionField(1, 1000, IdentityTransform(), "s"))
103+
tbl = catalog.create_table("default.empty_string_partition", schema, partition_spec=spec)
104+
tbl.append(pa.table({"s": [""]}, schema=pa.schema([pa.field("s", pa.large_string())])))
105+
106+
partition_summary = tbl.inspect.manifests().to_pydict()["partition_summaries"][0][0]
107+
assert partition_summary["lower_bound"] == ""
108+
assert partition_summary["upper_bound"] == ""

0 commit comments

Comments
 (0)