Skip to content

Commit d2e8579

Browse files
committed
feat: add client-side metadata loading in RestCatalog
1 parent 8edd7b8 commit d2e8579

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎pyiceberg/catalog/rest/__init__.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
)
7070
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec, assign_fresh_partition_spec_ids
7171
from pyiceberg.schema import Schema, assign_fresh_schema_ids
72+
from pyiceberg.serializers import FromInputFile
7273
from pyiceberg.table import (
7374
CommitTableRequest,
7475
CommitTableResponse,
@@ -1055,6 +1056,24 @@ def list_tables(self, namespace: str | Identifier) -> list[Identifier]:
10551056

10561057
@retry(**_RETRY_ARGS)
10571058
def load_table(self, identifier: str | Identifier) -> Table:
1059+
tr = self._load_table(identifier)
1060+
if self.properties.get(PREFER_CLIENT_SIDE_METADATA):
1061+
metadata_location = tr.metadata_location
1062+
if not metadata_location:
1063+
raise ValueError("Metadata location is required for client-side metadata loading")
1064+
io = load_file_io(properties=self.properties, location=metadata_location)
1065+
file = io.new_input(metadata_location)
1066+
metadata = FromInputFile.table_metadata(file)
1067+
return Table(
1068+
identifier=identifier,
1069+
metadata=metadata,
1070+
metadata_location=metadata_location,
1071+
io=self._load_file_io(metadata.properties, metadata_location),
1072+
catalog=self,
1073+
)
1074+
return tr
1075+
1076+
def _load_table(self, identifier: str | Identifier) -> Table:
10581077
self._check_endpoint(Capability.V1_LOAD_TABLE)
10591078
params = {}
10601079
if mode := self.properties.get(SNAPSHOT_LOADING_MODE):

0 commit comments

Comments
 (0)