adutra commented on code in PR #1405:
URL: https://github.com/apache/polaris/pull/1405#discussion_r2052324206
##########
service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -580,7 +586,18 @@ public Optional<LoadTableResponse> loadTableIfStale(
}
}
- return Optional.of(CatalogHandlers.loadTable(baseCatalog,
tableIdentifier));
+ Table table = baseCatalog.loadTable(tableIdentifier);
+ if (table instanceof BaseMetadataTable) {
+ throw new NoSuchTableException("Table does not exist: %s",
tableIdentifier.toString());
+ } else if (!(table instanceof BaseTable)) {
+ throw new IllegalStateException("Cannot wrap catalog that does not
produce BaseTable");
+ } else {
+ LoadTableResponse rawResponse =
+ LoadTableResponse.builder()
+ .withTableMetadata(((BaseTable) table).operations().current())
+ .build();
+ return Optional.of(filterResponseToSnapshots(rawResponse, snapshots));
+ }
Review Comment:
Couldn't you keep the call to `CatalogHandlers.loadTable`?
```suggestion
LoadTableResponse rawResponse = CatalogHandlers.loadTable(baseCatalog,
tableIdentifier);
return Optional.of(filterResponseToSnapshots(rawResponse, snapshots));
```
##########
integration-tests/src/main/java/org/apache/polaris/service/it/env/CatalogApi.java:
##########
@@ -149,6 +149,18 @@ public void dropTable(String catalog, TableIdentifier id) {
}
}
+ public int loadTable(String catalog, TableIdentifier id, String snapshots) {
+ String ns = RESTUtil.encodeNamespace(id.namespace());
+ try (Response res =
+ request(
+ "v1/{cat}/namespaces/" + ns + "/tables/{table}",
+ Map.of("cat", catalog, "table", id.name()),
+ Map.of("snapshots", snapshots))
+ .get()) {
+ return res.getStatus();
+ }
+ }
+
Review Comment:
Wouldn't it be nicer if this method actually returned the
`LoadTableResponse` object? This way your test could inspect the returned
snapshots.
```suggestion
public LoadTableResponse loadTable(String catalog, TableIdentifier id,
String snapshots) {
String ns = RESTUtil.encodeNamespace(id.namespace());
try (Response res =
request(
"v1/{cat}/namespaces/" + ns + "/tables/{table}",
Map.of("cat", catalog, "table", id.name()),
snapshots == null ? Map.of() : Map.of("snapshots",
snapshots))
.get()) {
if (res.getStatus() == Response.Status.OK.getStatusCode()) {
return res.readEntity(LoadTableResponse.class);
}
throw new RESTException(
"Unhandled error: %s",
((ErrorHandler) ErrorHandlers.defaultErrorHandler())
.parseResponse(res.getStatus(), res.readEntity(String.class)));
}
}
```
--
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]