JingsongLi commented on code in PR #1348:
URL: https://github.com/apache/paimon-rust/pull/1348#discussion_r4514110769


##########
crates/paimon/src/table/tag_manager.rs:
##########
@@ -69,17 +109,24 @@ impl TagManager {
 
     /// Check if a tag exists.
     pub async fn tag_exists(&self, tag_name: &str) -> crate::Result<bool> {
+        if let Some(rest) = &self.rest {
+            return Ok(rest.env.get_tag(&rest.branch, 
tag_name).await?.is_some());

Review Comment:
   **[P1] Keep numeric time travel working without the REST tag endpoint**
   
   `VERSION AS OF 1` becomes `scan.version`, so this probe now calls `GET 
/tags/1` before trying snapshot 1. I verified that a readable snapshot 1 
becomes inaccessible through this SQL syntax when the tag endpoint returns 501. 
The in-tree `paimon-rest-server` also has no tag route. [Java checks for a 
same-name tag 
first](https://github.com/apache/paimon/blob/57cca79870368bb64af235271124541cbcea1eeb/paimon-core/src/main/java/org/apache/paimon/table/source/snapshot/TimeTravelUtil.java#L153-L165),
 but that check uses table storage and does not require the REST tag endpoint.
   
   Could we preserve numeric snapshot and watermark resolution when the tag 
endpoint is unavailable, while keeping same-name tag precedence when it is 
supported and propagating real permission or table errors?



##########
crates/paimon/src/table/tag_manager.rs:
##########
@@ -181,9 +245,13 @@ impl TagManager {
         .await
     }
 
-    /// List all tag names sorted ascending. Returns an empty vector when the
-    /// tag directory does not exist.
+    /// List all tag names sorted ascending, from the catalog for REST tables
+    /// or from tag files otherwise. For filesystem tables, a missing tag 
directory
+    /// yields an empty list.
     pub async fn list_all_names(&self) -> crate::Result<Vec<String>> {
+        if let Some(rest) = &self.rest {
+            return rest.env.list_tag_names(&rest.branch).await;

Review Comment:
   **[P2] Keep legacy dot-segment tags from breaking unrelated `$tags` queries**
   
   Rejecting new `.` and `..` tags prevents new entries, but an existing 
catalog can still list one created by an older client. I seeded `..` and 
`release` in the mock and found that even `SELECT tag_name FROM orders$tags 
WHERE tag_name = 'release'` failed. Listing fetches every tag's details, and 
the URL path validator rejects `..` before the request. [Java's system 
table](https://github.com/apache/paimon/blob/57cca79870368bb64af235271124541cbcea1eeb/paimon-core/src/main/java/org/apache/paimon/table/system/TagsTable.java#L228-L272)
 can read `release` directly and handles the old name as the file `tag-..`.
   
   Could we handle legacy names separately so they cannot prevent other tags 
from being queried, while keeping the URL validation in place?



##########
crates/integrations/datafusion/src/procedures.rs:
##########
@@ -672,6 +673,27 @@ async fn proc_create_tag(
         .transpose()?;
     let time_retained = args.get("time_retained").map(String::as_str);
 
+    // The REST catalog owns tag metadata and resolves the snapshot itself,
+    // including the latest one when `snapshot_id` is omitted.
+    if let Some(rest_env) = table.rest_env() {
+        return match catalog
+            .create_tag_with_retention(

Review Comment:
   **[P2] Count files retained by catalog tags in `$referenced_files_size`**
   
   This can create a tag with no corresponding storage file, but [the 
referenced-files 
collector](https://github.com/apache/paimon-rust/blob/b86e45de5d4caba5362932997078cbd6f6987145/crates/paimon/src/table/referenced_files.rs#L226-L241)
 constructs a file-only `TagManager`. In a local repro, a REST tag kept 
snapshot 1, but removing the expired snapshot's metadata file dropped the 
reported manifest count from six to four. The two manifests are still 
referenced through the tag, so the documented orphan-size calculation can 
overcount.
   
   Could the collector use the catalog-aware tag manager for REST tables and 
cover a catalog-only tag that retains an expired snapshot?



-- 
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