You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "singhpk234 (via GitHub)" <gi...@apache.org> on 2026/01/09 23:22:46 UTC
Re: [PR] Core, Hive: Detect if a view already exists when registering a table [iceberg]
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org