nastra commented on code in PR #6512:
URL: https://github.com/apache/iceberg/pull/6512#discussion_r1232963122
##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -400,7 +403,43 @@ public void invalidateTable(SessionContext context,
TableIdentifier ident) {}
@Override
public Table registerTable(
SessionContext context, TableIdentifier ident, String
metadataFileLocation) {
- throw new UnsupportedOperationException("Register table is not supported");
+ checkIdentifierIsValid(ident);
+
+ Preconditions.checkArgument(
+ metadataFileLocation != null && !metadataFileLocation.isEmpty(),
+ "Invalid metadata file location: %s",
+ metadataFileLocation);
+
+ if (tableExists(context, ident)) {
+ throw new AlreadyExistsException("Table already exists: %s", ident);
+ }
+
+ RegisterTableRequest request =
+ ImmutableRegisterTableRequest.builder()
+ .identifier(ident)
+ .metadataFileLocation(metadataFileLocation)
+ .build();
+
+ LoadTableResponse response =
+ client.post(
+ paths.register(ident.namespace()),
+ request,
+ LoadTableResponse.class,
+ headers(context),
+ ErrorHandlers.tableErrorHandler());
+
+ AuthSession session = tableSession(response.config(), session(context));
+ RESTTableOperations ops =
+ new RESTTableOperations(
+ client,
+ paths.table(ident),
+ session::headers,
+ tableFileIO(context, response.config()),
+ response.tableMetadata());
+
+ trackFileIO(ops);
+
+ return new BaseTable(ops, fullTableName(ident));
Review Comment:
this also needs a parameter at the end to have proper metrics reporting:
`metricsReporter(paths.metrics(ident), session::headers)`
##########
open-api/rest-catalog-open-api.yaml:
##########
@@ -498,6 +498,58 @@ paths:
5XX:
$ref: '#/components/responses/ServerErrorResponse'
+ /v1/{prefix}/namespaces/{namespace}/tables/register:
+ parameters:
+ - $ref: '#/components/parameters/prefix'
+ - $ref: '#/components/parameters/namespace'
+
+ post:
+ tags:
+ - Catalog API
+ summary: Register a table in the given namespace using given metadata
file location
+ description:
+ Register a table using given metadata file location.
+
+ operationId: registerTable
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/RegisterTableRequest'
Review Comment:
we also need to define the schema for `RegisterTableRequest`
##########
open-api/rest-catalog-open-api.yaml:
##########
@@ -498,6 +498,58 @@ paths:
5XX:
$ref: '#/components/responses/ServerErrorResponse'
+ /v1/{prefix}/namespaces/{namespace}/tables/register:
Review Comment:
this seems to still have the old path
--
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]