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 13c9071c8b [core] RESTCatalog: update table api paths (#5248)
13c9071c8b is described below
commit 13c9071c8b9094ad5114a4b93c091198c879c399
Author: jerry <[email protected]>
AuthorDate: Mon Mar 10 20:40:55 2025 +0800
[core] RESTCatalog: update table api paths (#5248)
---
.../main/java/org/apache/paimon/rest/RESTCatalog.java | 10 ++++------
.../java/org/apache/paimon/rest/ResourcePaths.java | 10 +++++-----
.../java/org/apache/paimon/rest/RESTCatalogServer.java | 18 +++++-------------
.../java/org/apache/paimon/rest/ResourcePathsTest.java | 5 +++++
paimon-open-api/rest-catalog-open-api.yaml | 4 ++--
.../apache/paimon/open/api/RESTCatalogController.java | 13 ++++---------
6 files changed, 25 insertions(+), 35 deletions(-)
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 d7a4d281c1..b8a8984a37 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
@@ -152,7 +152,8 @@ public class RESTCatalog implements Catalog,
SupportsSnapshots, SupportsBranches
String warehouse = options.get(WAREHOUSE);
Map<String, String> queryParams =
StringUtils.isNotEmpty(warehouse)
- ? ImmutableMap.of(QUERY_PARAMETER_WAREHOUSE_KEY,
warehouse)
+ ? ImmutableMap.of(
+ QUERY_PARAMETER_WAREHOUSE_KEY,
RESTUtil.encodeString(warehouse))
: ImmutableMap.of();
baseHeaders = extractPrefixMap(context.options(), HEADER_PREFIX);
options =
@@ -382,7 +383,7 @@ public class RESTCatalog implements Catalog,
SupportsSnapshots, SupportsBranches
try {
response =
client.post(
-
resourcePaths.commitTable(identifier.getDatabaseName()),
+ resourcePaths.commitTable(),
request,
CommitTableResponse.class,
restAuthFunction);
@@ -479,10 +480,7 @@ public class RESTCatalog implements Catalog,
SupportsSnapshots, SupportsBranches
checkNotSystemTable(toTable, "renameTable");
try {
RenameTableRequest request = new RenameTableRequest(fromTable,
toTable);
- client.post(
- resourcePaths.renameTable(fromTable.getDatabaseName()),
- request,
- restAuthFunction);
+ client.post(resourcePaths.renameTable(), request,
restAuthFunction);
} catch (NoSuchResourceException e) {
if (!ignoreIfNotExists) {
throw new TableNotExistException(fromTable);
diff --git
a/paimon-core/src/main/java/org/apache/paimon/rest/ResourcePaths.java
b/paimon-core/src/main/java/org/apache/paimon/rest/ResourcePaths.java
index 301e862beb..aceca4b40b 100644
--- a/paimon-core/src/main/java/org/apache/paimon/rest/ResourcePaths.java
+++ b/paimon-core/src/main/java/org/apache/paimon/rest/ResourcePaths.java
@@ -48,7 +48,7 @@ public class ResourcePaths {
private final String prefix;
public ResourcePaths(String prefix) {
- this.prefix = prefix;
+ this.prefix = encodeString(prefix);
}
public String databases() {
@@ -81,12 +81,12 @@ public class ResourcePaths {
encodeString(objectName));
}
- public String renameTable(String databaseName) {
- return SLASH.join(V1, prefix, DATABASES, encodeString(databaseName),
TABLES, "rename");
+ public String renameTable() {
+ return SLASH.join(V1, prefix, TABLES, "rename");
}
- public String commitTable(String databaseName) {
- return SLASH.join(V1, prefix, DATABASES, encodeString(databaseName),
TABLES, "commit");
+ public String commitTable() {
+ return SLASH.join(V1, prefix, TABLES, "commit");
}
public String tableToken(String databaseName, String objectName) {
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 ed112e3843..ff8e3c6637 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
@@ -148,7 +148,7 @@ public class RESTCatalogServer {
this.configResponse = config;
this.prefix =
this.configResponse.getDefaults().get(RESTCatalogInternalOptions.PREFIX.key());
- ResourcePaths resourcePaths = new ResourcePaths(prefix);
+ this.resourcePaths = new ResourcePaths(prefix);
this.databaseUri = resourcePaths.databases();
Options conf = new Options();
this.configResponse.getDefaults().forEach(conf::setString);
@@ -257,6 +257,10 @@ public class RESTCatalogServer {
return mockResponse(configResponse, 200);
} else if (databaseUri.equals(request.getPath())) {
return databasesApiHandler(restAuthParameter.method(),
data);
+ } else if
(resourcePaths.renameTable().equals(request.getPath())) {
+ return renameTableHandle(restAuthParameter.data());
+ } else if
(resourcePaths.commitTable().equals(request.getPath())) {
+ return commitTableHandle(restAuthParameter.data());
} else if (request.getPath().startsWith(databaseUri)) {
String[] resources =
request.getPath()
@@ -276,10 +280,6 @@ public class RESTCatalogServer {
resources.length == 2 &&
resources[1].startsWith("tables");
boolean isTableDetails =
resources.length == 2 &&
resources[1].startsWith("table-details");
- boolean isTableRename =
- resources.length == 3
- && "tables".equals(resources[1])
- && "rename".equals(resources[2]);
boolean isViewRename =
resources.length == 3
&& "views".equals(resources[1])
@@ -293,10 +293,6 @@ public class RESTCatalogServer {
&& "tables".equals(resources[1])
&& !"rename".equals(resources[2])
&& !"commit".equals(resources[2]);
- boolean isTableCommit =
- resources.length == 3
- && "tables".equals(resources[1])
- && "commit".equals(resources[2]);
boolean isTableToken =
resources.length == 4
&& "tables".equals(resources[1])
@@ -385,10 +381,6 @@ public class RESTCatalogServer {
return getDataTokenHandle(identifier);
} else if (isTableSnapshot) {
return snapshotHandle(identifier);
- } else if (isTableRename) {
- return renameTableHandle(restAuthParameter.data());
- } else if (isTableCommit) {
- return commitTableHandle(restAuthParameter.data());
} else if (isTable) {
return tableHandle(
restAuthParameter.method(),
diff --git
a/paimon-core/src/test/java/org/apache/paimon/rest/ResourcePathsTest.java
b/paimon-core/src/test/java/org/apache/paimon/rest/ResourcePathsTest.java
index 18a8a3cf42..e3979c437a 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/ResourcePathsTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/ResourcePathsTest.java
@@ -33,5 +33,10 @@ public class ResourcePathsTest {
assertEquals(
"/v1/paimon/databases/test_db/tables/test_table%24snapshot",
resourcePaths.table(database, objectName));
+
+ resourcePaths = new ResourcePaths("paimon/aaaa");
+ assertEquals(
+
"/v1/paimon%2Faaaa/databases/test_db/tables/test_table%24snapshot",
+ resourcePaths.table(database, objectName));
}
}
diff --git a/paimon-open-api/rest-catalog-open-api.yaml
b/paimon-open-api/rest-catalog-open-api.yaml
index 688655901e..b1d185ea4b 100644
--- a/paimon-open-api/rest-catalog-open-api.yaml
+++ b/paimon-open-api/rest-catalog-open-api.yaml
@@ -410,7 +410,7 @@ paths:
$ref: '#/components/schemas/ErrorResponse'
"500":
description: Internal Server Error
- /v1/{prefix}/databases/{database}/tables/rename:
+ /v1/{prefix}/tables/rename:
post:
tags:
- table
@@ -449,7 +449,7 @@ paths:
$ref: '#/components/schemas/ErrorResponse'
"500":
description: Internal Server Error
- /v1/{prefix}/databases/{database}/tables/commit:
+ /v1/{prefix}/tables/commit:
post:
tags:
- table
diff --git
a/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
b/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
index 1e8c2efeed..536d8b7177 100644
---
a/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
+++
b/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
@@ -375,11 +375,8 @@ public class RESTCatalogController {
responseCode = "500",
content = {@Content(schema = @Schema())})
})
- @PostMapping("/v1/{prefix}/databases/{database}/tables/rename")
- public void renameTable(
- @PathVariable String prefix,
- @PathVariable String database,
- @RequestBody RenameTableRequest request) {}
+ @PostMapping("/v1/{prefix}/tables/rename")
+ public void renameTable(@PathVariable String prefix, @RequestBody
RenameTableRequest request) {}
@Operation(
summary = "Commit table",
@@ -396,11 +393,9 @@ public class RESTCatalogController {
responseCode = "500",
content = {@Content(schema = @Schema())})
})
- @PostMapping("/v1/{prefix}/databases/{database}/tables/commit")
+ @PostMapping("/v1/{prefix}/tables/commit")
public CommitTableResponse commitTable(
- @PathVariable String prefix,
- @PathVariable String database,
- @RequestBody CommitTableRequest request) {
+ @PathVariable String prefix, @RequestBody CommitTableRequest
request) {
return new CommitTableResponse(true);
}