Skip to content

[python] Implement branch CRUD on FileSystemCatalog#7755

Merged
JingsongLi merged 1 commit intoapache:masterfrom
TheR1sing3un:py-filesystem-catalog-branch-crud
May 3, 2026
Merged

[python] Implement branch CRUD on FileSystemCatalog#7755
JingsongLi merged 1 commit intoapache:masterfrom
TheR1sing3un:py-filesystem-catalog-branch-crud

Conversation

@TheR1sing3un
Copy link
Copy Markdown
Member

Purpose

Override the five branch CRUD methods on FileSystemCatalog so Python users on the local-catalog path get the same typed behavior as RESTCatalog (added in #7747). Sister PR to #7751 (FileSystemCatalog Tag CRUD); follow-up to #7747.

FileSystemCatalog previously inherited the Catalog ABC NotImplementedError stubs because the original PR (#7747) did not port the manager-layer wiring. The Python FileSystemBranchManager already exists at pypaimon/branch/filesystem_branch_manager.py and is reachable via FileStoreTable.branch_manager(), so this PR is a thin wrapper: each catalog method delegates to the manager and translates ValueError messages back into the typed catalog exception hierarchy (BranchAlreadyExistException, BranchNotExistException, TagNotExistException).

In scope

  • 5 method overrides on FileSystemCatalog: create_branch / drop_branch / rename_branch / fast_forward / list_branches.
  • New end-to-end test suite tests/filesystem_catalog_branch_test.py covering the same matrix as RESTCatalogBranchCRUDTest from [python] Add branch CRUD REST implementation to RESTCatalog #7747 (create / list / rename / drop / fast_forward — happy paths plus all typed-exception paths).
  • Removal of the now-stale FilesystemCatalogBranchInheritsNotImplementedTest class from rest/rest_branch_test.py (it asserted NotImplementedError, which no longer holds).

Out of scope

  • The FileSystemBranchManager "from-tag" path has a pre-existing bug: _copy_with_branch returns a SnapshotManager that doesn't switch to the new branch's path, so copy_file(src, dst) ends up with src == dst and raises SameFileError. That's a manager-level fix. The catalog-layer error translation for the from-tag path is still covered by test_create_branch_from_nonexistent_tag_raises. Two corresponding happy-path tests (test_create_branch_from_existing_tag and test_fast_forward_happy) are intentionally omitted with NOTE comments pointing at the bug.
  • ignore_if_exists parameter on create_branch — Java Catalog.createBranch does not expose it, and the manager-layer default (False) is sufficient.

Tests

Local run from paimon-python/:

pytest pypaimon/tests/filesystem_catalog_branch_test.py -v   # 13 passed
pytest pypaimon/tests/rest/rest_branch_test.py \
       pypaimon/tests/api/test_branch_dto_serde.py \
       pypaimon/tests/filesystem_catalog_tag_test.py \
       pypaimon/tests/branch_manager_test.py -v               # 59 passed
flake8 --config=dev/cfg.ini <touched files>                   # clean

Anti-divergence checklist

  • Method signatures match the Catalog ABC (identifier: Union[str, Identifier], tag_name=None).
  • Typed exceptions match those raised by RESTCatalog (BranchAlreadyExistException / BranchNotExistException / TagNotExistException / TableNotExistException).
  • list_branches returns List[str] (not PagedList), matching the strict Java alignment from [python] Add branch CRUD REST implementation to RESTCatalog #7747.
  • Substring matches verified against pypaimon/branch/filesystem_branch_manager.py master HEAD.

Generative AI disclosure

Drafted with assistance from a generative AI tool. All code, tests, and exception-translation logic were reviewed and validated by the contributor.

Override the five branch CRUD methods on FileSystemCatalog so that
Python users on the local-catalog path get the same behavior as
RESTCatalog (added in apache#7747). Each method delegates to
FileSystemBranchManager via FileStoreTable.branch_manager() and
translates the manager's ValueError messages back into the typed
Catalog exception hierarchy (BranchAlreadyExistException,
BranchNotExistException, TagNotExistException).

Sister PR to apache#7751 (FileSystemCatalog Tag CRUD); follow-up to apache#7747.
@JingsongLi
Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit 47f44ee into apache:master May 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants