anuragmantri commented on a change in pull request #3851:
URL: https://github.com/apache/iceberg/pull/3851#discussion_r780590087



##########
File path: 
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -210,7 +210,8 @@ protected void doRefresh() {
   @SuppressWarnings("checkstyle:CyclomaticComplexity")
   @Override
   protected void doCommit(TableMetadata base, TableMetadata metadata) {
-    String newMetadataLocation = writeNewMetadata(metadata, currentVersion() + 
1);
+    String newMetadataLocation = base == null && 
metadata.metadataFileLocation() != null ?
+        metadata.metadataFileLocation() : writeNewMetadata(metadata, 
currentVersion() + 1);

Review comment:
       Without this change, registering a table creates a new metadata file 
with a new version instead of using the version provided by the metadata file. 
Yes, the tests also rely on this. 

##########
File path: hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
##########
@@ -211,6 +214,18 @@ public void renameTable(TableIdentifier from, 
TableIdentifier originalTo) {
     }
   }
 
+  @Override
+  public org.apache.iceberg.Table registerTable(TableIdentifier identifier, 
String metadataFileLocation) {
+    Preconditions.checkArgument(isValidIdentifier(identifier), "Invalid 
identifier: %s", identifier);
+
+    TableOperations ops = newTableOps(identifier);
+    HadoopInputFile metadataFile = 
HadoopInputFile.fromLocation(metadataFileLocation, conf);

Review comment:
       Thanks for catching this. Updated to use `FileIO`.

##########
File path: api/src/main/java/org/apache/iceberg/catalog/Catalog.java
##########
@@ -340,6 +340,17 @@ default boolean dropTable(TableIdentifier identifier) {
    */
   Table loadTable(TableIdentifier identifier);
 
+  /**
+   * Register a table.

Review comment:
       Updated the java doc to mention this API will register a table with the 
catalog if it does not exist. It throws an exception if it exists. I have also 
added a unit test case.




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