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

   ### Purpose
   
   Linked issue: close #1341
   
   For tables managed by a REST catalog, the catalog owns tag and snapshot 
metadata. `create_tag`, `delete_tag`, `rename_tag` and 
`create_tag_from_timestamp` still read and wrote the table's `tag/` directory 
directly, and `rollback_to_timestamp` selected its target snapshot from storage 
before asking the catalog to roll back. The catalog and storage could drift 
apart without any error. This PR routes `create_tag` and `delete_tag` through 
the `Catalog` trait and rejects the procedures the catalog cannot support yet. 
Filesystem tables keep their behavior.
   
   ### Brief change log
   
   - **create_tag** (`procedures.rs`): REST tables call 
`Catalog::create_tag_with_retention`, forwarding the optional `snapshot_id` and 
`time_retained` unchanged. The server resolves the snapshot (the latest one 
when `snapshot_id` is omitted). `TagAlreadyExist` maps to the existing `Tag 
'...' already exists` error.
   - **delete_tag**: REST tables call `Catalog::delete_tag` for each 
comma-separated name with `ignore_if_not_exists`, so missing tags are still 
skipped. Other errors stop the batch. The name parsing (trim, skip empty names) 
is shared by both paths.
   - **rename_tag**: REST tables are rejected with `NotImplemented`, like 
`rename_branch`, since the REST catalog has no rename endpoint.
   - **create_tag_from_timestamp** and **rollback_to_timestamp**: REST tables 
are rejected with `NotImplemented`, like `create_tag_from_watermark`, because 
timestamp selection reads snapshots from storage, which may lag behind the 
catalog. `rollback_to_timestamp` no longer sends a REST rollback for a snapshot 
selected from storage.
   - **Mock REST server** (`mock_server.rs`): record create and delete tag 
requests, add tag error injection and a sorted `tags` accessor. Tag names in 
get and delete paths are decoded from the raw path, as branch names already 
are, so `+` (space) stays distinct from `%2B`.
   
   ### Tests
   
   - `crates/integrations/datafusion/tests/rest_management_procedures.rs`:
     - `test_create_tag_goes_through_rest_catalog`: latest-snapshot, 
explicit-snapshot and retention creates; names with spaces, `+` and non-ASCII; 
a storage-only tag file does not block creation; existing tag and missing 
snapshot errors; the exact `CreateTagRequest`s sent.
     - `test_delete_tag_goes_through_rest_catalog`: batch deletion with 
missing, empty, repeated and trimmed names; a storage-only tag is deleted 
through the catalog; an invalid name stops the batch without rolling back 
earlier deletions.
     - `test_tag_catalog_errors_do_not_fall_back_to_storage`: 400, 403, 404 
(missing table) and 501 errors from both procedures are returned without 
touching storage.
     - `test_unsupported_tag_procedures_rejected_on_rest_catalog`: 
`replace_tag`, `rename_tag`, `create_tag_from_timestamp` and 
`rollback_to_timestamp` are rejected before reading invalid storage metadata. 
This replaces the separate `replace_tag` test.
     - `test_snapshot_selection_procedures_reject_readable_rest_catalog_table` 
(renamed from the `create_tag_from_watermark` test): the watermark and 
timestamp procedures are rejected even when storage is readable but trails the 
catalog.
     - Every test also checks that table storage is unchanged.
   - `crates/integrations/datafusion/tests/procedures.rs`: 
`test_delete_multiple_tags` now covers trimmed, empty and missing names on 
filesystem tables.
   
   ### API and Format
   
   - `sys.create_tag` and `sys.delete_tag` now update the REST catalog for REST 
catalog tables instead of writing table storage.
   - `sys.rename_tag`, `sys.create_tag_from_timestamp` and 
`sys.rollback_to_timestamp` now return `NotImplemented` for REST catalog tables.
   - No storage format change.
   
   ### Documentation
   
   - `docs/src/sql.md`: describe the REST behavior of `create_tag` and 
`delete_tag`, add a `rename_tag` section, and note that 
`create_tag_from_timestamp` and `rollback_to_timestamp` are not supported for 
REST catalog tables.
   
   🤖 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