singhpk234 commented on code in PR #15010:
URL: https://github.com/apache/iceberg/pull/15010#discussion_r2677870414


##########
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:
   I wonder if view of same name existing under namespace, is something client 
concern or more of a catalog concern ? 
   what happens by the time view exists check is done and before the table 
register happens some one creates a view in the catalog ? 
   
   catalog such as Apache Polaris already such validation to make sure it 
rejects the table creation if there is view of that name or vice versa not 
totally sure about Hive Catalog 
   
   
https://github.com/apache/polaris/blob/main/persistence/relational-jdbc/src/main/resources/h2/schema-v1.sql#L54



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