Skip to content
Closed
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
16 changes: 8 additions & 8 deletions paimon-python/pypaimon/api/rest_api.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,24 @@ def list_tables_paged(
def create_table(self, identifier: Identifier, schema: Schema) -> None:
request = CreateTableRequest(identifier, schema)
return self.client.post(
self.resource_paths.tables(identifier.database_name),
self.resource_paths.tables(identifier.get_database_name()),
request,
self.rest_auth_function)

def get_table(self, identifier: Identifier) -> GetTableResponse:
return self.client.get(
self.resource_paths.table(
identifier.database_name,
identifier.object_name),
identifier.get_database_name(),
identifier.get_object_name()),
GetTableResponse,
self.rest_auth_function,
)

def drop_table(self, identifier: Identifier) -> GetTableResponse:
return self.client.delete(
self.resource_paths.table(
identifier.database_name,
identifier.object_name),
identifier.get_database_name(),
identifier.get_object_name()),
self.rest_auth_function,
)

Expand All @@ -250,8 +250,8 @@ def rename_table(self, source_identifier: Identifier, target_identifier: Identif
def load_table_token(self, identifier: Identifier) -> GetTableTokenResponse:
return self.client.get(
self.resource_paths.table_token(
identifier.database_name,
identifier.object_name),
identifier.get_database_name(),
identifier.get_object_name()),
GetTableTokenResponse,
self.rest_auth_function,
)
Expand Down Expand Up @@ -282,7 +282,7 @@ def commit_snapshot(
request = CommitTableRequest(table_uuid, snapshot, statistics)
response = self.client.post_with_response_type(
self.resource_paths.commit_table(
identifier.database_name, identifier.object_name),
identifier.get_database_name(), identifier.get_object_name()),
request,
CommitTableResponse,
self.rest_auth_function
Expand Down
26 changes: 13 additions & 13 deletions paimon-python/pypaimon/common/identifier.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
@dataclass
class Identifier:

database_name: str = json_field("database", default=None)
object_name: str = json_field("object", default=None)
branch_name: Optional[str] = json_field("branch", default=None)
database: str = json_field("database", default=None)
object: str = json_field("object", default=None)
branch: Optional[str] = json_field("branch", default=None)

@classmethod
def create(cls, database_name: str, object_name: str) -> "Identifier":
return cls(database_name, object_name)
def create(cls, database: str, object: str) -> "Identifier":
return cls(database, object)

@classmethod
def from_string(cls, full_name: str) -> "Identifier":
Expand All @@ -46,21 +46,21 @@ def from_string(cls, full_name: str) -> "Identifier":
raise ValueError("Invalid identifier format: {}".format(full_name))

def get_full_name(self) -> str:
if self.branch_name:
return "{}.{}.{}".format(self.database_name, self.object_name, self.branch_name)
return "{}.{}".format(self.database_name, self.object_name)
if self.branch:
return "{}.{}.{}".format(self.database, self.object, self.branch)
return "{}.{}".format(self.database, self.object)

def get_database_name(self) -> str:
return self.database_name
return self.database

def get_table_name(self) -> str:
return self.object_name
return self.object

def get_object_name(self) -> str:
return self.object_name
return self.object

def get_branch_name(self) -> Optional[str]:
return self.branch_name
return self.branch

def is_system_table(self) -> bool:
return self.object_name.startswith('$')
return self.object.startswith('$')
Empty file modified paimon-python/pypaimon/schema/data_types.py
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions paimon-python/pypaimon/snapshot/catalog_snapshot_commit.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def commit(self, snapshot: Snapshot, branch: str, statistics: List[PartitionStat
Exception: If commit fails
"""
new_identifier = Identifier(
database_name=self.identifier.get_database_name(),
object_name=self.identifier.get_table_name(),
branch_name=branch
database=self.identifier.get_database_name(),
object=self.identifier.get_table_name(),
branch=branch
)

# Call catalog's commit_snapshot method
Expand Down
18 changes: 11 additions & 7 deletions paimon-python/pypaimon/tests/rest/rest_server.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def _route_request(self, method: str, resource_path: str, parameters: Dict[str,
source = self.table_metadata_store.get(source_table.get_full_name())
self.table_metadata_store.update({destination_table.get_full_name(): source})
source_table_dir = (Path(self.data_path) / self.warehouse
/ source_table.database_name / source_table.object_name)
/ source_table.get_database_name() / source_table.get_object_name())
destination_table_dir = (Path(self.data_path) / self.warehouse
/ destination_table.database_name / destination_table.object_name)
/ destination_table.get_database_name() / destination_table.get_object_name())
if not source_table_dir.exists():
destination_table_dir.mkdir(parents=True)
else:
Expand Down Expand Up @@ -352,7 +352,7 @@ def _handle_table_resource(self, method: str, path_parts: List[str],
table_name_part = table_parts[0]
branch_part = table_parts[1]
# Recreate identifier without branch for lookup
lookup_identifier = Identifier.create(identifier.database_name, table_name_part)
lookup_identifier = Identifier.create(identifier.get_database_name(), table_name_part)
else:
lookup_identifier = identifier
branch_part = None
Expand Down Expand Up @@ -431,8 +431,10 @@ def _tables_handle(self, method: str = None, data: str = None, database_name: st
create_table.identifier, 0, create_table.schema, str(uuid.uuid4()), False
)
self.table_metadata_store.update({create_table.identifier.get_full_name(): table_metadata})
table_dir = Path(
self.data_path) / self.warehouse / database_name / create_table.identifier.object_name / 'schema'
table_dir = (
Path(self.data_path) / self.warehouse / database_name /
create_table.identifier.get_object_name() / 'schema'
)
if not table_dir.exists():
table_dir.mkdir(parents=True)
with open(table_dir / "schema-0", "w") as f:
Expand All @@ -446,7 +448,8 @@ def _table_handle(self, method: str, data: str, identifier: Identifier) -> Tuple
if identifier.get_full_name() not in self.table_metadata_store:
raise TableNotExistException(identifier)
table_metadata = self.table_metadata_store[identifier.get_full_name()]
table_path = f'file://{self.data_path}/{self.warehouse}/{identifier.database_name}/{identifier.object_name}'
table_path = (f'file://{self.data_path}/{self.warehouse}/'
f'{identifier.get_database_name()}/{identifier.get_object_name()}')
schema = table_metadata.schema.to_schema()
response = self.mock_table(identifier, table_metadata, table_path, schema)
return self._mock_response(response, 200)
Expand Down Expand Up @@ -522,7 +525,8 @@ def _write_snapshot_files(self, identifier: Identifier, snapshot, statistics):
import uuid

# Construct table path: {warehouse}/{database}/{table}
table_path = os.path.join(self.data_path, self.warehouse, identifier.database_name, identifier.object_name)
table_path = os.path.join(self.data_path, self.warehouse, identifier.get_database_name(),
identifier.get_object_name())

# Create directory structure
snapshot_dir = os.path.join(table_path, "snapshot")
Expand Down