nastra commented on code in PR #6512:
URL: https://github.com/apache/iceberg/pull/6512#discussion_r1134061896


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -391,7 +393,41 @@ 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 =
+        RegisterTableRequest.builder()
+            .withName(ident.name())
+            .withMetadataFielLocation(metadataFileLocation)

Review Comment:
   typo in `withMetadataFielLocation` -> should be `withMetadataFileLocation`



##########
core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java:
##########
@@ -335,7 +341,14 @@ public <T extends RESTResponse> T handleRequest(
           TableIdentifier ident = identFromPathVars(vars);
           return castResponse(responseType, CatalogHandlers.loadTable(catalog, 
ident));
         }
-
+      case REGISTER_TABLE:
+        {
+          Namespace namespace = namespaceFromPathVars(vars);
+          RegisterTableRequest request = 
castRequest(RegisterTableRequest.class, body);
+          request.validate();

Review Comment:
   I think this isn't necessary to do here as it's already being done in 
`CatalogHandlers.registerTable`



##########
open-api/rest-catalog-open-api.yaml:
##########
@@ -496,6 +496,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: Create a table in the given namespace using given metadata file 
location

Review Comment:
   Create a table -> Register a table



-- 
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]

Reply via email to