This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new d538997b6f [rest] Add tagNamePrefix definition for listTagsPaged
(#6947)
d538997b6f is described below
commit d538997b6f9a0a3cf8e8a26158926c5c418fbd2a
Author: kevin <[email protected]>
AuthorDate: Sun Jan 4 13:11:19 2026 +0800
[rest] Add tagNamePrefix definition for listTagsPaged (#6947)
---
docs/static/rest-catalog-open-api.yaml | 5 +++++
.../src/main/java/org/apache/paimon/rest/RESTApi.java | 10 ++++++++--
.../java/org/apache/paimon/catalog/AbstractCatalog.java | 5 ++++-
.../src/main/java/org/apache/paimon/catalog/Catalog.java | 8 ++++++--
.../java/org/apache/paimon/catalog/DelegateCatalog.java | 7 +++++--
.../src/main/java/org/apache/paimon/rest/RESTCatalog.java | 7 +++++--
.../java/org/apache/paimon/rest/RESTCatalogServer.java | 11 +++++++++++
.../test/java/org/apache/paimon/rest/RESTCatalogTest.java | 15 ++++++++++-----
8 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/docs/static/rest-catalog-open-api.yaml
b/docs/static/rest-catalog-open-api.yaml
index 7641ab5cb9..fcf5c53d11 100644
--- a/docs/static/rest-catalog-open-api.yaml
+++ b/docs/static/rest-catalog-open-api.yaml
@@ -1147,6 +1147,11 @@ paths:
in: query
schema:
type: string
+ - name: tagNamePrefix
+ description: A prefix for tag names. All tags will be returned if
not set or empty.
+ in: query
+ schema:
+ type: string
responses:
"200":
description: OK
diff --git a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
index 57d2e2989c..a6bf162d55 100644
--- a/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
+++ b/paimon-api/src/main/java/org/apache/paimon/rest/RESTApi.java
@@ -147,6 +147,7 @@ public class RESTApi {
public static final String VIEW_NAME_PATTERN = "viewNamePattern";
public static final String FUNCTION_NAME_PATTERN = "functionNamePattern";
public static final String PARTITION_NAME_PATTERN = "partitionNamePattern";
+ public static final String TAG_NAME_PREFIX = "tagNamePrefix";
public static final long TOKEN_EXPIRATION_SAFE_TIME_MILLIS = 3_600_000L;
@@ -917,18 +918,23 @@ public class RESTApi {
* max results.
* @param pageToken Optional parameter indicating the next page token
allows list to be start
* from a specific point.
+ * @param tagNamePrefix A prefix for tag names. All tags will be returned
if not set or empty.
* @return {@link PagedList}: elements and nextPageToken.
* @throws NoSuchResourceException Exception thrown on HTTP 404 means the
table not exists
* @throws ForbiddenException Exception thrown on HTTP 403 means don't
have the permission for
* this table
*/
public PagedList<String> listTagsPaged(
- Identifier identifier, @Nullable Integer maxResults, @Nullable
String pageToken) {
+ Identifier identifier,
+ @Nullable Integer maxResults,
+ @Nullable String pageToken,
+ @Nullable String tagNamePrefix) {
ListTagsResponse response =
client.get(
resourcePaths.tags(
identifier.getDatabaseName(),
identifier.getObjectName()),
- buildPagedQueryParams(maxResults, pageToken),
+ buildPagedQueryParams(
+ maxResults, pageToken,
Pair.of(TAG_NAME_PREFIX, tagNamePrefix)),
ListTagsResponse.class,
restAuthFunction);
List<String> tags = response.tags();
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
index 1fd023aa9f..6c98d0fb26 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
@@ -521,7 +521,10 @@ public abstract class AbstractCatalog implements Catalog {
@Override
public PagedList<String> listTagsPaged(
- Identifier identifier, @Nullable Integer maxResults, @Nullable
String pageToken)
+ Identifier identifier,
+ @Nullable Integer maxResults,
+ @Nullable String pageToken,
+ @Nullable String tagNamePrefix)
throws TableNotExistException {
throw new UnsupportedOperationException();
}
diff --git a/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
index dd9521b12e..74e35dde3d 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/Catalog.java
@@ -631,7 +631,7 @@ public interface Catalog extends AutoCloseable {
* <li>{@link #listBranches(Identifier)}.
* <li>{@link #getTag(Identifier, String)}.
* <li>{@link #createTag(Identifier, String, Long, String, boolean)}.
- * <li>{@link #listTagsPaged(Identifier, Integer, String)}.
+ * <li>{@link #listTagsPaged(Identifier, Integer, String, String)}.
* <li>{@link #deleteTag(Identifier, String)}.
* </ul>
*/
@@ -830,6 +830,7 @@ public interface Catalog extends AutoCloseable {
* max results.
* @param pageToken Optional parameter indicating the next page token
allows list to be start
* from a specific point.
+ * @param tagNamePrefix A prefix for tag names. All tags will be returned
if not set or empty.
* @return a list of the names of tags with provided page size in this
table and next page
* token, or a list of the names of all tags in this table if the
catalog does not {@link
* #supportsListObjectsPaged()}.
@@ -838,7 +839,10 @@ public interface Catalog extends AutoCloseable {
* #supportsVersionManagement()} or it does not {@link
#supportsListByPattern()}
*/
PagedList<String> listTagsPaged(
- Identifier identifier, @Nullable Integer maxResults, @Nullable
String pageToken)
+ Identifier identifier,
+ @Nullable Integer maxResults,
+ @Nullable String pageToken,
+ @Nullable String tagNamePrefix)
throws TableNotExistException;
/**
diff --git
a/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
b/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
index eff0c0b229..5e286191de 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/DelegateCatalog.java
@@ -252,9 +252,12 @@ public abstract class DelegateCatalog implements Catalog {
@Override
public PagedList<String> listTagsPaged(
- Identifier identifier, @Nullable Integer maxResults, @Nullable
String pageToken)
+ Identifier identifier,
+ @Nullable Integer maxResults,
+ @Nullable String pageToken,
+ @Nullable String tagNamePrefix)
throws TableNotExistException {
- return wrapped.listTagsPaged(identifier, maxResults, pageToken);
+ return wrapped.listTagsPaged(identifier, maxResults, pageToken,
tagNamePrefix);
}
@Override
diff --git a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
index eeaede934d..d8254bb58f 100644
--- a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
@@ -1053,10 +1053,13 @@ public class RESTCatalog implements Catalog {
*/
@Override
public PagedList<String> listTagsPaged(
- Identifier identifier, @Nullable Integer maxResults, @Nullable
String pageToken)
+ Identifier identifier,
+ @Nullable Integer maxResults,
+ @Nullable String pageToken,
+ @Nullable String tagNamePrefix)
throws TableNotExistException {
try {
- return api.listTagsPaged(identifier, maxResults, pageToken);
+ return api.listTagsPaged(identifier, maxResults, pageToken,
tagNamePrefix);
} catch (NoSuchResourceException e) {
throw new TableNotExistException(identifier);
} catch (ForbiddenException e) {
diff --git
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
index 65b3a65ff8..544b490385 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
@@ -153,6 +153,7 @@ import static org.apache.paimon.rest.RESTApi.PAGE_TOKEN;
import static org.apache.paimon.rest.RESTApi.PARTITION_NAME_PATTERN;
import static org.apache.paimon.rest.RESTApi.TABLE_NAME_PATTERN;
import static org.apache.paimon.rest.RESTApi.TABLE_TYPE;
+import static org.apache.paimon.rest.RESTApi.TAG_NAME_PREFIX;
import static org.apache.paimon.rest.RESTApi.VIEW_NAME_PATTERN;
import static org.apache.paimon.rest.ResourcePaths.FUNCTIONS;
import static org.apache.paimon.rest.ResourcePaths.FUNCTION_DETAILS;
@@ -1736,6 +1737,16 @@ public class RESTCatalogServer {
// GET
/v1/{prefix}/databases/{database}/tables/{table}/tags
// Page list tags
List<String> tags = new
ArrayList<>(tagManager.allTagNames());
+
+ // Filter by tagNamePrefix if provided
+ String tagNamePrefix = parameters.get(TAG_NAME_PREFIX);
+ if (StringUtils.isNotEmpty(tagNamePrefix)) {
+ tags =
+ tags.stream()
+ .filter(tag ->
matchNamePattern(tag, tagNamePrefix))
+ .collect(Collectors.toList());
+ }
+
if (tags.isEmpty()) {
response = new
ListTagsResponse(Collections.emptyList(), null);
return mockResponse(response, 200);
diff --git
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index b0910e3e65..288c925ceb 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -1966,15 +1966,20 @@ public abstract class RESTCatalogTest extends
CatalogTestBase {
SnapshotNotExistException.class,
() -> restCatalog.createTag(identifier, "my_tag_v3", 99999L,
null, false));
- // Test listTags
- PagedList<String> tags = restCatalog.listTagsPaged(identifier, null,
"my_tag");
+ // Test listTags for pageToken
+ PagedList<String> tags = restCatalog.listTagsPaged(identifier, 1,
null, null);
+ tags = restCatalog.listTagsPaged(identifier, 1,
tags.getNextPageToken(), null);
assertThat(tags.getElements()).containsExactlyInAnyOrder("my_tag_v2");
- tags = restCatalog.listTagsPaged(identifier, null, null);
+ tags = restCatalog.listTagsPaged(identifier, null, null, null);
assertThat(tags.getElements()).containsExactlyInAnyOrder("my_tag",
"my_tag_v2");
+ // Test listTags for tagNamePrefix
+ tags = restCatalog.listTagsPaged(identifier, 1, null, "my_tag_v2");
+ assertThat(tags.getElements()).containsExactlyInAnyOrder("my_tag_v2");
+
// Test deleteTag
restCatalog.deleteTag(identifier, "my_tag");
- tags = restCatalog.listTagsPaged(identifier, null, null);
+ tags = restCatalog.listTagsPaged(identifier, null, null, null);
assertThat(tags.getElements()).containsExactlyInAnyOrder("my_tag_v2");
// Test deleteTag with non-existent tag
@@ -1988,7 +1993,7 @@ public abstract class RESTCatalogTest extends
CatalogTestBase {
// Delete remaining tag
restCatalog.deleteTag(identifier, "my_tag_v2");
- tags = restCatalog.listTagsPaged(identifier, null, null);
+ tags = restCatalog.listTagsPaged(identifier, null, null, null);
assertThat(tags.getElements()).isEmpty();
}