ajantha-bhat commented on code in PR #14868:
URL: https://github.com/apache/iceberg/pull/14868#discussion_r2629733208
##########
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:
Good observation.
I saw that `CatalogUtil.fullTableName` was more better as it handles slash
and uri names. I also saw that same thing was used in `HiveViewOperations`.
I think probably we should unify `ViewUtil.fullViewName` and
`CatalogUtil.fullTableName` use it everywhere. In a separate PR.
For this PR now, I updated back the changes to use `ViewUtil.fullViewName`.
--
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]