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
2 changes: 1 addition & 1 deletion pyiceberg/table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ def from_metadata(cls, metadata_location: str, properties: Properties = EMPTY_DI
identifier=("static-table", metadata_location),
metadata_location=metadata_location,
metadata=metadata,
io=load_file_io({**properties, **metadata.properties}),
io=load_file_io({**properties, **metadata.properties}, location=metadata_location),
catalog=NoopCatalog("static-table"),
)

Expand Down
23 changes: 22 additions & 1 deletion tests/table/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
In,
)
from pyiceberg.expressions.visitors import bind
from pyiceberg.io import PY_IO_IMPL, load_file_io
from pyiceberg.io import PY_IO_IMPL, FileIO, load_file_io
from pyiceberg.partitioning import PartitionField, PartitionSpec
from pyiceberg.schema import Schema
from pyiceberg.table import (
Expand Down Expand Up @@ -1989,3 +1989,24 @@ def test_build_large_partition_predicate(table_v2: Table) -> None:
)

bind(table_v2.metadata.schema(), expr, case_sensitive=True)


def test_static_table_forwards_location_to_table_file_io(metadata_location: str, monkeypatch: pytest.MonkeyPatch) -> None:
seen_locations: list[str | None] = []
real_load_file_io = load_file_io

def _spy(*args: Any, **kwargs: Any) -> FileIO:
if "location" in kwargs:
seen_locations.append(kwargs["location"])
elif len(args) >= 2:
seen_locations.append(args[1])
else:
seen_locations.append(None)
return real_load_file_io(*args, **kwargs)

monkeypatch.setattr("pyiceberg.table.load_file_io", _spy)

StaticTable.from_metadata(metadata_location)

assert seen_locations, "expected at least one load_file_io call"
assert all(loc is not None for loc in seen_locations), f"load_file_io called without a location: {seen_locations}"