You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2026/09/03 11:58:48 UTC
[PR] Skip metadata loads for table, view, and namespace existence checks [polaris]
ayushtkn opened a new pull request, #5438:
URL: https://github.com/apache/polaris/pull/5438
`tableExists`, `viewExists` and `namespaceExists` each resolve and authorize the entity, then load it in full and discard the result. All three methods return void — the adapter turns a normal return into a `204` with no body — and all three carried a
```
// TODO: Just skip CatalogHandlers for this one maybe.
```
Resolution has already done what the endpoint asks. `resolveAndAuthorizeBasicTableLikeOperationOrThrow` throws `notFoundExceptionForTableLikeEntity` when the resolved leaf is absent or of the wrong subtype, so everything after it re-establishes a fact already in hand.
* What a local table or view check cost
`loadTable` reaches `newTableOps(ident).current()` → `doRefresh()`, which spends two things per request:
- A second resolution of the path. `doRefresh` calls `getPassthroughResolvedPath(...)`, deliberately bypassing the authz resolution set the request just built, so the entity is resolved from the metastore twice.
- A read and parse of the whole metadata file. `refreshFromMetadataLocation(...)` → `TableMetadataParser.read(fileIO, location)`: an object-storage GET plus a full` JSON` parse of metadata that is then discarded. `loadView` is the same shape through `ViewMetadataParser`.
* What a local namespace check cost
Much less, stated plainly. `LocalIcebergCatalog.loadNamespaceMetadata` reads the already-resolved path via `getResolvedPath(...)` and returns the entity's properties — no storage access, no second resolution. Removing it saves a lookup and a map copy. It is included for consistency across the three endpoints and for the federated benefit below, not for a local performance win.
* What every federated check saves
Federated catalogs are passthrough, so a Polaris record does not guarantee the entity is still on the remote and the remote must still be consulted. It is now asked whether the entity `exists` rather than made to `load` it.
Against a REST-backed catalog that is a `HEAD` in place of a `GET` returning full metadata — `RESTSessionCatalog.tableExists issues client.head(...)`. A catalog that does not override exists falls through to the `Catalog/ViewCatalog` interface default, which loads and catches: the same cost as before, never worse.
Because `exists` returns `false` where `load` threw, the not-found is now raised explicitly — `notFoundExceptionForTableLikeEntity` for tables and views, `noSuchNamespaceException` for namespaces — so response statuses for them stay unchanged.
## Checklist
- [ ] 🛡️ Don't disclose security issues! (contact security@apache.org)
- [ ] 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
- [ ] 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
- [ ] 💡 Added comments for complex logic
- [ ] 🧾 Updated `CHANGELOG.md` (if needed)
- [ ] 📚 Updated documentation in `site/content/in-dev/unreleased` (if needed)
--
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: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Skip metadata loads for table, view, and namespace existence checks [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #5438:
URL: https://github.com/apache/polaris/pull/5438#discussion_r3963214271
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -340,8 +341,10 @@ public void namespaceExists(Namespace namespace) {
// existence is also missing.
authorizeBasicNamespaceOperationOrThrow(op, namespace);
- // TODO: Just skip CatalogHandlers for this one maybe
- catalogHandlerUtils().loadNamespace(namespaceCatalog, namespace);
+ if (!(baseCatalog instanceof LocalIcebergCatalog)
+ && !namespaceCatalog.namespaceExists(namespace)) {
+ throw noSuchNamespaceException(namespace);
Review Comment:
nit: the logic is correct, but a bit obscure. The fact that we delegate the existence check to `namespaceCatalog` is not apparent at first glance... It might be easier to read this code it had nested `if` statements.... with a comment about why we do not have to do the check for local catalog.
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1384,8 +1387,12 @@ public void tableExists(TableIdentifier tableIdentifier) {
resolveAndAuthorizeBasicTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier);
- // TODO: Just skip CatalogHandlers for this one maybe
- catalogHandlerUtils().loadTable(baseCatalog, tableIdentifier);
+ // A federated catalog is loaded rather than asked with tableExists, because tableExists
+ // reports a synthetic metadata table such as ns.orders.snapshots as present while loadTable
+ // rejects it as not found. Loading keeps the two answers in agreement for those identifiers.
+ if (!(baseCatalog instanceof LocalIcebergCatalog)) {
Review Comment:
Could you add a comment why loading is not needed for local catalogs?
--
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: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Skip metadata loads for table, view, and namespace existence checks [polaris]
Posted by "flyingImer (via GitHub)" <gi...@apache.org>.
flyingImer commented on code in PR #5438:
URL: https://github.com/apache/polaris/pull/5438#discussion_r3961483385
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1321,8 +1324,11 @@ public void tableExists(TableIdentifier tableIdentifier) {
resolveAndAuthorizeBasicTableLikeOperationOrThrow(
op, PolarisEntitySubType.ICEBERG_TABLE, tableIdentifier);
- // TODO: Just skip CatalogHandlers for this one maybe
- catalogHandlerUtils().loadTable(baseCatalog, tableIdentifier);
+ if (!(baseCatalog instanceof LocalIcebergCatalog)
+ && !baseCatalog.tableExists(tableIdentifier)) {
+ throw notFoundExceptionForTableLikeEntity(
Review Comment:
Is the change in metadata-table existence semantics intentional? IIRC, with Hadoop federation, tableExists can return true for a synthetic metadata table such as ns.orders.snapshots, while CatalogHandlerUtils.loadTable explicitly rejects BaseMetadataTable. http HEAD method therefore changes from 404 to 204 while GET still returns 404. If intentional, could we cover this case and note the status change in the PR description?
--
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: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Skip metadata loads for table, view, and namespace existence checks [polaris]
Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b merged PR #5438:
URL: https://github.com/apache/polaris/pull/5438
--
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: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org