This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch branch-1.2
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-1.2 by this push:
new e6e1c2bd5b [Cherry-pick to branch-1.2] [#10397] fix(iceberg): Fix
wrong namespaces when listing tables or views (#10398) (#10401)
e6e1c2bd5b is described below
commit e6e1c2bd5b594f841a5004a80fdc8b1b50c6124e
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Mar 12 20:14:29 2026 +0800
[Cherry-pick to branch-1.2] [#10397] fix(iceberg): Fix wrong namespaces
when listing tables or views (#10398) (#10401)
**Cherry-pick Information:**
- Original commit: e30102470a5b9faedbd135949cb6a3fad5b91504
- Target branch: `branch-1.2`
- Status: ✅ Clean cherry-pick (no conflicts)
Co-authored-by: roryqi <[email protected]>
---
.../gravitino/iceberg/service/rest/IcebergTableOperations.java | 2 +-
.../gravitino/iceberg/service/rest/IcebergViewOperations.java | 2 +-
.../iceberg/integration/test/IcebergAuthorizationIT.java | 8 +++++++-
.../iceberg/integration/test/IcebergViewAuthorizationIT.java | 6 ++++++
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
index 1bac5d64b6..e15de6d51b 100644
---
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
+++
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergTableOperations.java
@@ -552,7 +552,7 @@ public class IcebergTableOperations {
List<TableIdentifier> filteredIdentifiers = new ArrayList<>();
for (NameIdentifier ident : idents) {
filteredIdentifiers.add(
- TableIdentifier.of(Namespace.of(ident.namespace().level(0)),
ident.name()));
+ TableIdentifier.of(Namespace.of(ident.namespace().level(2)),
ident.name()));
}
return ListTablesResponse.builder()
.addAll(filteredIdentifiers)
diff --git
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
index 86e3d66b5a..c94ef3a340 100644
---
a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
+++
b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java
@@ -353,7 +353,7 @@ public class IcebergViewOperations {
List<TableIdentifier> filteredIdentifiers = new ArrayList<>();
for (NameIdentifier ident : idents) {
filteredIdentifiers.add(
- TableIdentifier.of(Namespace.of(ident.namespace().level(0)),
ident.name()));
+ TableIdentifier.of(Namespace.of(ident.namespace().level(2)),
ident.name()));
}
return ListTablesResponse.builder()
.addAll(filteredIdentifiers)
diff --git
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java
index eb20d4672e..63fcc10a59 100644
---
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java
+++
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergAuthorizationIT.java
@@ -271,7 +271,13 @@ public class IcebergAuthorizationIT extends BaseIT {
}
protected Set<String> listTableNames(String database) {
- return convertToStringSet(sql("SHOW TABLES in %s", database), 1);
+ List<Object[]> objects = sql("SHOW TABLES in %s", database);
+ for (Object[] row : objects) {
+ if (row.length > 1) {
+ Assertions.assertEquals(database, String.valueOf(row[0]));
+ }
+ }
+ return convertToStringSet(objects, 1);
}
protected List<Object[]> sql2(String query) {
diff --git
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergViewAuthorizationIT.java
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergViewAuthorizationIT.java
index 7dfd3c6d83..2ffd92c8e2 100644
---
a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergViewAuthorizationIT.java
+++
b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/integration/test/IcebergViewAuthorizationIT.java
@@ -488,6 +488,12 @@ public class IcebergViewAuthorizationIT extends
IcebergAuthorizationIT {
private Set<String> listViewNames(String database) {
List<Object[]> rows = sql("SHOW VIEWS in %s", database);
+ rows.forEach(
+ row -> {
+ if (row.length > 1) {
+ Assertions.assertEquals(database, row[0]);
+ }
+ });
return rows.stream()
.map(row -> row.length > 1 ? (String) row[1] : (String) row[0])
.collect(Collectors.toSet());