Skip to content
Draft
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
49 changes: 49 additions & 0 deletions paimon-python/pypaimon/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,52 @@ def list_tags_paged(
raise NotImplementedError(
"list_tags_paged is not supported by this catalog."
)

def repair_table(self, identifier: Union[str, Identifier],
check_data_files: bool = False, dry_run: bool = True) -> 'RepairReport':
"""Repair the metadata of a single table.

Verifies the consistency of the snapshot -> manifest list -> manifest
-> data file chain and optionally fixes issues found.

Args:
identifier: Table identifier (Identifier or string).
check_data_files: If True, verify data file existence (slow).
dry_run: If True, only report issues without fixing.

Returns:
RepairReport describing issues found and fixes applied.
"""
raise NotImplementedError(
"repair_table is not supported by this catalog."
)

def repair_database(self, database_name: str,
check_data_files: bool = False, dry_run: bool = True) -> 'List[RepairReport]':
"""Repair all tables in a database.

Args:
database_name: Name of the database.
check_data_files: If True, verify data file existence (slow).
dry_run: If True, only report issues without fixing.

Returns:
List of RepairReport, one per table.
"""
raise NotImplementedError(
"repair_database is not supported by this catalog."
)

def repair_catalog(self, check_data_files: bool = False, dry_run: bool = True) -> 'List[RepairReport]':
"""Repair all tables in all databases in the catalog.

Args:
check_data_files: If True, verify data file existence (slow).
dry_run: If True, only report issues without fixing.

Returns:
List of RepairReport, one per table.
"""
raise NotImplementedError(
"repair_catalog is not supported by this catalog."
)
32 changes: 32 additions & 0 deletions paimon-python/pypaimon/catalog/filesystem_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,35 @@ def list_branches(
identifier = Identifier.from_string(identifier)
table = self.get_table(identifier)
return table.branch_manager().branches()

def repair_table(self, identifier: Union[str, Identifier],
check_data_files: bool = False, dry_run: bool = True) -> 'RepairReport':
"""Repair the metadata of a single table."""
from pypaimon.operation.repair import repair_table as _repair_table

if not isinstance(identifier, Identifier):
identifier = Identifier.from_string(identifier)
table_path = self.get_table_path(identifier)
if not self.file_io.exists(table_path):
raise TableNotExistException(identifier)
return _repair_table(self.file_io, table_path, branch=identifier.get_branch_name(),
check_data_files=check_data_files, dry_run=dry_run)

def repair_database(self, database_name: str,
check_data_files: bool = False, dry_run: bool = True) -> 'List[RepairReport]':
"""Repair all tables in a database."""
from pypaimon.operation.repair import repair_database as _repair_database

try:
self.get_database(database_name)
except DatabaseNotExistException:
raise
return _repair_database(self.file_io, self.warehouse, database_name,
check_data_files=check_data_files, dry_run=dry_run)

def repair_catalog(self, check_data_files: bool = False, dry_run: bool = True) -> 'List[RepairReport]':
"""Repair all tables in all databases in the catalog."""
from pypaimon.operation.repair import repair_catalog as _repair_catalog

return _repair_catalog(self.file_io, self.warehouse,
check_data_files=check_data_files, dry_run=dry_run)
16 changes: 16 additions & 0 deletions paimon-python/pypaimon/operation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
Loading
Loading