pvary commented on code in PR #8907: URL: https://github.com/apache/iceberg/pull/8907#discussion_r1405826355
########## hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java: ########## @@ -264,6 +265,163 @@ public void renameTable(TableIdentifier from, TableIdentifier originalTo) { } } + @Override + public boolean viewExists(TableIdentifier identifier) { + return HiveCatalogUtil.isTableWithTypeExists(clients, identifier, TableType.VIRTUAL_VIEW); + } + + @Override + public boolean dropView(TableIdentifier identifier) { Review Comment: What do we do with the metadata of the table? How does `dropView` work for other catalogs? Does it remove the metadata files? ########## hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java: ########## @@ -234,15 +225,25 @@ public void renameTable(TableIdentifier from, TableIdentifier originalTo) { String fromName = from.name(); try { - Table table = clients.run(client -> client.getTable(fromDatabase, fromName)); - HiveOperationsBase.validateTableIsIceberg(table, fullTableName(name, from)); - - table.setDbName(toDatabase); - table.setTableName(to.name()); + Table fromTable = clients.run(client -> client.getTable(fromDatabase, fromName)); + HiveOperationsBase.validateTableIsIceberg(fromTable, fullTableName(name, from)); + Optional<Table> toTable = + HiveCatalogUtil.loadHmsTableIfPresent(clients, toDatabase, to.name()); + if (toTable.isPresent()) { + if (toTable.get().getTableType().equalsIgnoreCase(TableType.VIRTUAL_VIEW.name())) { + throw new org.apache.iceberg.exceptions.AlreadyExistsException( + "Cannot rename %s to %s. View already exists", from, to); + } else { + throw new org.apache.iceberg.exceptions.AlreadyExistsException( + "Cannot rename %s to %s. Table already exists", from, to); + } + } Review Comment: nit: newline -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org