Skip to content

Commit

Permalink
[bug] [REST] Dont remove identifier root (apache#1172)
Browse files Browse the repository at this point in the history
* dont remove identifier root

* remove catalog in identifier tuple
  • Loading branch information
kevinjqliu authored Sep 13, 2024
1 parent aae39b5 commit 0dc5408
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ def _split_identifier_for_path(
self, identifier: Union[str, Identifier, TableIdentifier], kind: IdentifierKind = IdentifierKind.TABLE
) -> Properties:
if isinstance(identifier, TableIdentifier):
if identifier.namespace.root[0] == self.name:
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), kind.value: identifier.name}
else:
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), kind.value: identifier.name}
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), kind.value: identifier.name}
identifier_tuple = self._identifier_to_validated_tuple(identifier)

return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind.value: identifier_tuple[-1]}
Expand Down Expand Up @@ -578,6 +575,7 @@ def _create_table(
fresh_partition_spec = assign_fresh_partition_spec_ids(partition_spec, iceberg_schema, fresh_schema)
fresh_sort_order = assign_fresh_sort_order_ids(sort_order, iceberg_schema, fresh_schema)

identifier = self._identifier_to_tuple_without_catalog(identifier)
namespace_and_table = self._split_identifier_for_path(identifier)
if location:
location = location.rstrip("/")
Expand Down Expand Up @@ -659,6 +657,7 @@ def register_table(self, identifier: Union[str, Identifier], metadata_location:
Raises:
TableAlreadyExistsError: If the table already exists
"""
identifier = self._identifier_to_tuple_without_catalog(identifier)
namespace_and_table = self._split_identifier_for_path(identifier)
request = RegisterTableRequest(
name=namespace_and_table["table"],
Expand Down

0 comments on commit 0dc5408

Please sign in to comment.