-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
improvementPR that improves existing functionalityPR that improves existing functionality
Description
Feature Request / Improvement
It looks like we just load the table and fail if it raises an exception:
iceberg/api/src/main/java/org/apache/iceberg/catalog/SessionCatalog.java
Lines 180 to 187 in f2d6275
| 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:
iceberg/open-api/rest-catalog-open-api.yaml
Lines 833 to 864 in 97e034b
| 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
Labels
improvementPR that improves existing functionalityPR that improves existing functionality