You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/07/26 00:45:51 UTC

[GitHub] [iceberg] yabola commented on a diff in pull request #5327: Support force option on registerTable procedure

yabola commented on code in PR #5327:
URL: https://github.com/apache/iceberg/pull/5327#discussion_r929429419


##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:
##########
@@ -235,19 +235,21 @@ public void renameTable(TableIdentifier from, TableIdentifier originalTo) {
   }
 
   @Override
-  public org.apache.iceberg.Table registerTable(TableIdentifier identifier, String metadataFileLocation) {
+  public org.apache.iceberg.Table registerTable(TableIdentifier identifier,
+      String metadataFileLocation, boolean force) {
     Preconditions.checkArgument(isValidIdentifier(identifier), "Invalid identifier: %s", identifier);
 
-    // Throw an exception if this table already exists in the catalog.
-    if (tableExists(identifier)) {
+    // Throw an exception if this table already exists in the catalog and no force option.
+    if (tableExists(identifier) && !force) {
       throw new org.apache.iceberg.exceptions.AlreadyExistsException("Table already exists: %s", identifier);
     }
+    HiveTableOperations ops = (HiveTableOperations) newTableOps(identifier);
+    TableMetadata base = ops.current();

Review Comment:
   If pass in base, we can change the `commit` method less, otherwise, the logic of commit checking meta will be incorrect. `commit` method means changing table meta from base to newMeta. I think this is good for maintaining the  existing logic.



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