Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyiceberg/table/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,13 @@ def _files(self, snapshot_id: int | None = None, data_file_filter: set[DataFileC

Returns:
pa.Table: Concatenated file metadata from all manifests in the snapshot.

Raises:
ValueError: If the specified snapshot does not exist.
"""
import pyarrow as pa

if not snapshot_id and not self.tbl.metadata.current_snapshot():
if snapshot_id is None and not self.tbl.metadata.current_snapshot():
return self._get_files_schema().empty_table()

snapshot = self._get_snapshot(snapshot_id)
Expand Down
9 changes: 9 additions & 0 deletions tests/table/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,12 @@ def test_inspect_after_promoting_then_dropping_partition_column(catalog: InMemor
assert tbl.inspect.manifests().to_pydict()["partition_summaries"][0] == [
{"contains_null": False, "contains_nan": False, "lower_bound": "10", "upper_bound": "20"}
]


@pytest.mark.parametrize("method", ["files", "data_files", "delete_files"])
def test_inspect_files_with_snapshot_id_zero_on_table_without_snapshots(catalog: InMemoryCatalog, method: str) -> None:
tbl = catalog.create_table("default.no_snapshots", Schema(NestedField(1, "x", LongType(), required=False)))

assert getattr(tbl.inspect, method)().num_rows == 0
with pytest.raises(ValueError, match="Cannot find snapshot with ID 0"):
getattr(tbl.inspect, method)(snapshot_id=0)
Loading