Skip to content

Use HEAD operation for tableExists in REST-Catalog #10993

@Fokko

Description

@Fokko

Feature Request / Improvement

It looks like we just load the table and fail if it raises an exception:

default boolean tableExists(SessionContext context, TableIdentifier ident) {
try {
loadTable(context, ident);
return true;
} catch (NoSuchTableException e) {
return false;
}
}

Instead we would love to override this for the REST-Catalog, and use the HEAD call instead:

head:
tags:
- Catalog API
summary: Check if a table exists
operationId: tableExists
description:
Check if a table exists within a given namespace. The response does not contain a body.
responses:
204:
description: Success, no content
400:
$ref: '#/components/responses/BadRequestErrorResponse'
401:
$ref: '#/components/responses/UnauthorizedResponse'
403:
$ref: '#/components/responses/ForbiddenResponse'
404:
description:
Not Found - NoSuchTableException, Table not found
content:
application/json:
schema:
$ref: '#/components/schemas/IcebergErrorResponse'
examples:
TableToLoadDoesNotExist:
$ref: '#/components/examples/NoSuchTableError'
419:
$ref: '#/components/responses/AuthenticationTimeoutResponse'
503:
$ref: '#/components/responses/ServiceUnavailableResponse'
5XX:
$ref: '#/components/responses/ServerErrorResponse'

This will be more friendly on the catalog since it doesn't have to load the metadata, and will also return a faster response. We also use this when creating a view to double-check if there is not a table with the same name:

if (tableExists(context, identifier)) {

The HEAD operation will be much faster than trying to load the table.

Query engine

None

Willingness to contribute

  • I can contribute this improvement/feature independently
  • I would be willing to contribute this improvement/feature with guidance from the Iceberg community
  • I cannot contribute this improvement/feature at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementPR that improves existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions