sunyuhan1998 commented on code in PR #10895:
URL: https://github.com/apache/gravitino/pull/10895#discussion_r3246492439
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java:
##########
@@ -131,10 +159,61 @@ public DescribeTableResponse describeTable(
Optional.ofNullable(table.properties().get(LANCE_TABLE_VERSION))
.map(Long::valueOf)
.orElse(null));
-
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(table.properties()));
+
+ if (credentialPrivilege != null) {
+ response.setStorageOptions(
+ buildVendedStorageOptions(catalogName, catalog, table,
credentialPrivilege));
+ } else {
+
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(table.properties()));
+ }
+
return response;
}
+ private Map<String, String> buildVendedStorageOptions(
+ String catalogName, Catalog catalog, Table table, CredentialPrivilege
credentialPrivilege) {
Review Comment:
Thanks for the suggestion. Our Lance server accesses catalogs through
`GravitinoClient.loadCatalog()`, which returns a client-side proxy `Catalog`.
In the Gravitino core, `BaseCatalog` already has a built-in
`catalogCredentialManager()`, but we cannot access it from the client proxy
since it is not part of the `Catalog` interface.
That is why we currently cache `CatalogCredentialManager` separately in a
`ConcurrentHashMap` keyed by catalog name. To follow your suggestion, we could
create a wrapper like:
```java
class LanceCatalogWrapper {
private final Catalog catalog;
private final CatalogCredentialManager credentialManager;
LanceCatalogWrapper(Catalog catalog) {
this.catalog = catalog;
this.credentialManager = new
CatalogCredentialManager(catalog.name(), catalog.properties());
}
}
```
And modify `GravitinoLanceNamespaceWrapper` to return this wrapper instead
of raw `Catalog`. This would make the association explicit. Would you like us
to go with this approach? Or do you have a different design in mind?
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceTableOperations.java:
##########
@@ -131,10 +159,61 @@ public DescribeTableResponse describeTable(
Optional.ofNullable(table.properties().get(LANCE_TABLE_VERSION))
.map(Long::valueOf)
.orElse(null));
-
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(table.properties()));
+
+ if (credentialPrivilege != null) {
+ response.setStorageOptions(
+ buildVendedStorageOptions(catalogName, catalog, table,
credentialPrivilege));
+ } else {
+
response.setStorageOptions(LancePropertiesUtils.getLanceStorageOptions(table.properties()));
+ }
+
return response;
}
+ private Map<String, String> buildVendedStorageOptions(
+ String catalogName, Catalog catalog, Table table, CredentialPrivilege
credentialPrivilege) {
Review Comment:
Done. We have replaced `catalogName` with `catalog.name()` as the cache key
and removed the redundant `catalogName` variable.
--
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]