roryqi commented on code in PR #10586:
URL: https://github.com/apache/gravitino/pull/10586#discussion_r3042713007
##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -414,4 +440,114 @@ private TableMetadataCache
loadTableMetadataCache(IcebergConfig config, Catalog
expireMinutes);
return cache;
}
+
+ private LoadTableResponse loadTableInternal(TableIdentifier ident) {
+ if (!(catalog instanceof RESTCatalog)) {
+ return CatalogHandlers.loadTable(catalog, ident);
+ }
+
+ Table table = catalog.loadTable(ident);
+
+ if (table instanceof BaseTable) {
+ Map<String, String> properties = retrieveFileIOProperties(table.io());
+ return LoadTableResponse.builder()
+ .withTableMetadata(((BaseTable) table).operations().current())
+ .addAllConfig(
+ MapUtils.getFilteredMap(
+ properties, key ->
catalogPropertiesToClientKeys.contains(key)))
+ // Keep only credential fields from FileIO properties before
returning them to the client.
+
.addAllConfig(CredentialPropertyUtils.filterCredentialProperties(properties))
+ .build();
+ } else if (table instanceof BaseMetadataTable) {
+ // metadata tables are loaded on the client side, return
NoSuchTableException for now
+ throw new NoSuchTableException("Table does not exist: %s",
ident.toString());
+ }
+
+ throw new IllegalStateException("Cannot wrap catalog that does not produce
BaseTable");
+ }
+
+ private LoadTableResponse createTableInternal(Namespace namespace,
CreateTableRequest request) {
+ if (!(catalog instanceof RESTCatalog)) {
+ return CatalogHandlers.createTable(catalog, namespace, request);
+ }
+
+ request.validate();
+
+ TableIdentifier ident = TableIdentifier.of(namespace, request.name());
+ Table table =
+ catalog
+ .buildTable(ident, request.schema())
+ .withLocation(request.location())
+ .withPartitionSpec(request.spec())
+ .withSortOrder(request.writeOrder())
+ .withProperties(request.properties())
+ .create();
+
+ if (table instanceof BaseTable) {
+ Map<String, String> properties = retrieveFileIOProperties(table.io());
+ return LoadTableResponse.builder()
+ .withTableMetadata(((BaseTable) table).operations().current())
+ .addAllConfig(
+ MapUtils.getFilteredMap(
+ properties, key ->
catalogPropertiesToClientKeys.contains(key)))
+ // Keep only credential fields from FileIO properties before
returning them to the client.
+
.addAllConfig(CredentialPropertyUtils.filterCredentialProperties(properties))
+ .build();
+ }
+
+ throw new IllegalStateException("Cannot wrap catalog that does not produce
BaseTable");
+ }
+
+ public LoadTableResponse stageTableCreateInternal(
Review Comment:
Yes, this should be private.
--
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]