This is an automated email from the ASF dual-hosted git repository.
baiyangtx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 0401720c7 [AMORO-2743]add doAs before call catalog method in
IcebergCatalog class (#2744)
0401720c7 is described below
commit 0401720c7c101a9c1c6ae6132906226fe7a9d836
Author: Wang Tao <[email protected]>
AuthorDate: Mon Apr 15 11:34:46 2024 +0800
[AMORO-2743]add doAs before call catalog method in IcebergCatalog class
(#2744)
issue_2743 add doAs before call catalog method
---
.../arctic/formats/iceberg/IcebergCatalog.java | 53 ++++++++++++++--------
1 file changed, 34 insertions(+), 19 deletions(-)
diff --git
a/core/src/main/java/com/netease/arctic/formats/iceberg/IcebergCatalog.java
b/core/src/main/java/com/netease/arctic/formats/iceberg/IcebergCatalog.java
index ccfc17464..5f3d5545e 100644
--- a/core/src/main/java/com/netease/arctic/formats/iceberg/IcebergCatalog.java
+++ b/core/src/main/java/com/netease/arctic/formats/iceberg/IcebergCatalog.java
@@ -51,9 +51,11 @@ public class IcebergCatalog implements FormatCatalog {
@Override
public List<String> listDatabases() {
- return asNamespaceCatalog().listNamespaces().stream()
- .map(ns -> ns.level(0))
- .collect(Collectors.toList());
+ return metaStore.doAs(
+ () ->
+ asNamespaceCatalog().listNamespaces().stream()
+ .map(ns -> ns.level(0))
+ .collect(Collectors.toList()));
}
@Override
@@ -64,38 +66,51 @@ public class IcebergCatalog implements FormatCatalog {
@Override
public boolean exist(String database, String table) {
TableIdentifier identifier = TableIdentifier.of(database, table);
- return icebergCatalog.tableExists(identifier);
+ return metaStore.doAs(() -> icebergCatalog.tableExists(identifier));
}
@Override
public void createDatabase(String database) {
- asNamespaceCatalog().createNamespace(Namespace.of(database));
+ metaStore.doAs(
+ () -> {
+ asNamespaceCatalog().createNamespace(Namespace.of(database));
+ return null;
+ });
}
@Override
public void dropDatabase(String database) {
- asNamespaceCatalog().dropNamespace(Namespace.of(database));
+ metaStore.doAs(
+ () -> {
+ asNamespaceCatalog().dropNamespace(Namespace.of(database));
+ return null;
+ });
}
@Override
public List<String> listTables(String database) {
- return icebergCatalog.listTables(Namespace.of(database)).stream()
- .map(TableIdentifier::name)
- .collect(Collectors.toList());
+ return metaStore.doAs(
+ () ->
+ icebergCatalog.listTables(Namespace.of(database)).stream()
+ .map(TableIdentifier::name)
+ .collect(Collectors.toList()));
}
@Override
public AmoroTable<?> loadTable(String database, String table) {
- try {
- Table icebergTable =
icebergCatalog.loadTable(TableIdentifier.of(database, table));
- return IcebergTable.newIcebergTable(
- com.netease.arctic.table.TableIdentifier.of(icebergCatalog.name(),
database, table),
- icebergTable,
- metaStore,
- properties);
- } catch (NoSuchTableException e) {
- throw new com.netease.arctic.NoSuchTableException(e);
- }
+ return metaStore.doAs(
+ () -> {
+ try {
+ Table icebergTable =
icebergCatalog.loadTable(TableIdentifier.of(database, table));
+ return IcebergTable.newIcebergTable(
+
com.netease.arctic.table.TableIdentifier.of(icebergCatalog.name(), database,
table),
+ icebergTable,
+ metaStore,
+ properties);
+ } catch (NoSuchTableException e) {
+ throw new com.netease.arctic.NoSuchTableException(e);
+ }
+ });
}
private SupportsNamespaces asNamespaceCatalog() {