rdblue commented on a change in pull request #688: [ISSUE #672] Add 
SupportsNamespaces for 'HadoopCatalog' and 'HiveCatalog'
URL: https://github.com/apache/incubator-iceberg/pull/688#discussion_r361730149
 
 

 ##########
 File path: hive/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
 ##########
 @@ -188,6 +330,48 @@ protected String defaultWarehouseLocation(TableIdentifier 
tableIdentifier) {
         tableIdentifier.name());
   }
 
+  public  Map<String, String> convertToMetadata(Database database) {
+    Map<String, String> nameMap = Maps.newHashMap();
+
+    nameMap.put("name", database.getName());
+    nameMap.put("location", database.getLocationUri());
+    nameMap.put("comment", database.getDescription());
+    database.getParameters().forEach(nameMap::put);
+
+    return nameMap;
+  }
+
+  public  Database convertToDatabase(Namespace namespace, Map<String, String> 
meta) {
+    String warehouseLocation = conf.get("hive.metastore.warehouse.dir");
+
+    if (namespace.levels().length != 1) {
+      throw new NoSuchNamespaceException("Namespace does not exist: %s", 
namespace);
+    }
+    if (!meta.containsKey("location")) {
+      Preconditions.checkNotNull(warehouseLocation,
+          "Warehouse location is not set: hive.metastore.warehouse.dir=null");
 
 Review comment:
   What happens when the location URI is not set on the `Database` passed to 
Hive? Does Hive assign one itself?
   
   If Hive assigns a location, then I think this doesn't need to check that the 
client's warehouse location is set.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to