rdblue commented on code in PR #4950:
URL: https://github.com/apache/iceberg/pull/4950#discussion_r889051190
##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -209,12 +211,40 @@ private LoadTableResponse loadInternal(SessionContext
context, TableIdentifier i
@Override
public Table loadTable(SessionContext context, TableIdentifier identifier) {
- LoadTableResponse response = loadInternal(context, identifier);
+ MetadataTableType metadataType;
+ LoadTableResponse response;
+ try {
+ response = loadInternal(context, identifier);
+ metadataType = null;
+
+ } catch (NoSuchTableException original) {
+ metadataType = MetadataTableType.from(identifier.name());
+ if (metadataType != null) {
+ // attempt to load a metadata table using the identifier's namespace
as the base table
+ TableIdentifier baseIdent =
TableIdentifier.of(identifier.namespace().levels());
+ try {
+ response = loadInternal(context, baseIdent);
+ } catch (NoSuchTableException ignored) {
+ // the base table does not exist
+ throw original;
+ }
+ } else {
+ // name is not a metadata table
+ throw original;
+ }
+ }
+
Pair<RESTClient, FileIO> clients = tableClients(response.config());
AuthSession session = tableSession(response.config(), session(context));
RESTTableOperations ops = new RESTTableOperations(
clients.first(), paths.table(identifier), session::headers,
clients.second(), response.tableMetadata());
- return new BaseTable(ops, fullTableName(identifier));
+
+ BaseTable table = new BaseTable(ops, fullTableName(identifier));
+ if (metadataType != null) {
+ return MetadataTableUtils.createMetadataTableInstance(table,
metadataType);
+ }
+
+ return table;
Review Comment:
Yeah, the intent was to either return or wrap the base table like Kyle said.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]