nastra commented on code in PR #15010:
URL: https://github.com/apache/iceberg/pull/15010#discussion_r2681183545
##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:
##########
@@ -911,4 +911,27 @@ public View create() {
return super.create();
}
}
+
+ @Override
+ public org.apache.iceberg.Table registerTable(
+ 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 table");
+
+ // throw an exception in case the table identifier already exists as a
table/view
+ if (tableExists(identifier)) {
+ throw new org.apache.iceberg.exceptions.AlreadyExistsException(
+ "Table already exists: %s", identifier);
+ }
+
+ if (viewExists(identifier)) {
+ throw new org.apache.iceberg.exceptions.AlreadyExistsException(
+ "View with same name already exists: %s", identifier);
+ }
Review Comment:
for the Hive catalog I don't think we have any other option and need to
check it here. For the REST catalog this is obviously different, because the
server-side can provide such atomic guarantees. The case you're describing
would fail with Hive when the second commit tries to do a refresh, which would
then lead to seeing the view already existing. This is similar to other catalog
implementations we have
--
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]