SteNicholas opened a new pull request, #1346:
URL: https://github.com/apache/paimon-rust/pull/1346

   ### Purpose
   
   Linked issue: close #1340
   
   `RESTCatalog` already implements `create_branch`, `drop_branch`, 
`fast_forward` and `list_branches`, but the DataFusion procedures did not use 
them: `sys.create_branch` and `sys.delete_branch` refused every REST-managed 
table, and `sys.fast_forward` did not exist. This PR routes the branch 
procedures of REST tables through the `Catalog` trait instead of 
`BranchManager`, so the REST catalog owns branch metadata and the procedures do 
not write table storage. Filesystem tables keep their behavior.
   
   ```sql
   CALL sys.create_branch(table => 'db.tbl', branch => 'dev', tag => 'release', 
ignore_if_exists => true);
   CALL sys.delete_branch(table => 'db.tbl', branch => 'dev,qa');
   CALL sys.fast_forward(table => 'db.tbl', branch => 'release_branch');
   ```
   
   ### Brief change log
   
   - **create_branch** (`procedures.rs`): remove the REST refusal and call 
`Catalog::create_branch`. The local checks (branch name, no `$`, not a format 
table, main-branch source table) still run first. With `ignore_if_exists`, 
`Catalog::list_branches` is checked first, so an existing branch is a no-op 
without resolving the tag, as on the filesystem path and in Java. A 
`BranchAlreadyExist` from a concurrent create is also treated as success.
   - **delete_branch**: remove the REST refusal. After the existing comma 
split, `validate_branch_name` and the `scan.primary-branch` / 
`scan.fallback-branch` guard, call `Catalog::drop_branch` for each name and 
skip missing branches (`BranchNotExist`). Other errors stop the batch.
   - **fast_forward** (new): add `CALL sys.fast_forward(table => '...', branch 
=> '...')`. REST tables call `Catalog::fast_forward`. Filesystem tables are 
refused with `NotImplemented`; porting Java 
`FileSystemBranchManager.fastForward` is a separate change.
   - **Main-branch source**: `delete_branch` and `fast_forward` require a 
main-branch source table on REST, as `create_branch` already does, because the 
catalog addresses branches through the main table.
   - **Mock REST server** (`mock_server.rs`): add the list, create, drop and 
fast-forward branch endpoints with error injection. Branch names are decoded 
from the raw path so `+` (space) stays distinct from `%2B`. The existing policy 
error helper is renamed to `error_response` and shared by both.
   
   No core change is needed: `RESTCatalog` already maps 409 to 
`BranchAlreadyExist`, 404 to `TagNotExist` / `BranchNotExist`, and 403 to 
`Forbidden: <message>`.
   
   ### Tests
   
   - `crates/integrations/datafusion/tests/rest_management_procedures.rs` 
(replacing the tests that asserted the old refusals):
     - `test_create_branch_goes_through_rest_catalog`: plain, from-tag and 
`ignore_if_exists` creates; names with spaces, `+` and non-ASCII; a 
storage-only branch directory does not block creation; `list_branches` errors 
with `ignore_if_exists`; existing branch and missing tag; 409 from a concurrent 
create; 403 errors.
     - `test_delete_branch_goes_through_rest_catalog`: batch deletion with 
missing, empty, repeated and space-preserving names; scan-configured branch 
guards; a 403 stops the batch.
     - `test_fast_forward_goes_through_rest_catalog`: success, missing branch, 
403.
     - `test_branch_procedures_validate_names_on_rest_catalog`: invalid names 
are rejected locally by all three procedures.
     - `test_branch_procedures_reject_unsupported_rest_tables`: missing tables, 
non-main source tables, external engine tables and format tables.
     - Every test also checks that table storage is unchanged.
   - `crates/integrations/datafusion/tests/procedures.rs`: 
`test_fast_forward_validates_arguments_and_rejects_filesystem_tables`.
   
   ### API and Format
   
   - `sys.create_branch` and `sys.delete_branch` now work on REST catalog 
tables instead of being refused.
   - New SQL procedure: `sys.fast_forward` (REST catalog tables only).
   - No storage format change.
   
   ### Documentation
   
   - `docs/src/sql.md`: describe the REST behavior of `create_branch`, and add 
`delete_branch` and `fast_forward` sections.
   - `procedures.rs` module docs: add `delete_branch` and `fast_forward` to the 
list.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to