gaborkaszab commented on code in PR #14868:
URL: https://github.com/apache/iceberg/pull/14868#discussion_r2627857651


##########
core/src/main/java/org/apache/iceberg/view/BaseMetastoreViewCatalog.java:
##########
@@ -298,4 +299,25 @@ public Transaction replaceTransaction() {
       return super.replaceTransaction();
     }
   }
+
+  @Override
+  public View registerView(TableIdentifier identifier, String 
metadataFileLocation) {
+    Preconditions.checkArgument(
+        identifier != null && isValidIdentifier(identifier), "Invalid 
identifier: %s", identifier);
+    Preconditions.checkArgument(
+        metadataFileLocation != null && !metadataFileLocation.isEmpty(),
+        "Cannot register an empty metadata file location as a view");
+
+    // Throw an exception if this view already exists in the catalog.
+    if (viewExists(identifier)) {
+      throw new AlreadyExistsException("View already exists: %s", identifier);
+    }
+
+    ViewOperations ops = newViewOps(identifier);
+    InputFile metadataFile = ((BaseViewOperations) 
ops).io().newInputFile(metadataFileLocation);
+    ViewMetadata metadata = ViewMetadataParser.read(metadataFile);
+    ops.commit(null, metadata);
+
+    return new BaseView(ops, fullTableName(name(), identifier));

Review Comment:
   `BaseMetastoreViewCatalog.create()` creates the BaseView like this:
   `return new BaseView(ops, ViewUtil.fullViewName(name(), identifier));`
   Note, it constructs the view name using `ViewUtil`. Shouldn't we follow that 
here?



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