szlta commented on code in PR #3226:
URL: https://github.com/apache/hive/pull/3226#discussion_r854208599


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTableUtil.java:
##########
@@ -43,6 +45,26 @@ private IcebergTableUtil() {
 
   }
 
+  /**
+   * Constructs the table properties needed for the Iceberg table loading by 
retrieving the information from the
+   * hmsTable. It then calls {@link IcebergTableUtil#getTable(Configuration, 
Properties)} with these properties.
+   * @param configuration a Hadoop configuration
+   * @param hmsTable the HMS table
+   * @return the Iceberg table
+   */
+  static Table getTable(Configuration configuration, 
org.apache.hadoop.hive.metastore.api.Table hmsTable) {
+    Properties properties = new Properties();
+    properties.setProperty(Catalogs.NAME, 
TableIdentifier.of(hmsTable.getDbName(), hmsTable.getTableName()).toString());
+    if (hmsTable.getSd() != null) {
+      properties.setProperty(Catalogs.LOCATION, 
hmsTable.getSd().getLocation());
+    }
+    if (hmsTable.getParameters().containsKey(InputFormatConfig.CATALOG_NAME)) {
+      properties.setProperty(
+          InputFormatConfig.CATALOG_NAME, 
hmsTable.getParameters().get(InputFormatConfig.CATALOG_NAME));
+    }

Review Comment:
   nit: could do with one look-up only by calling get() beforehand, and 
refactoring the if condition into null check.



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