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_r361728706
 
 

 ##########
 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");
+    }
+
+    Database database  = new Database();
+    Map<String, String> parameter = Maps.newHashMap();
+
+    database.setName(namespace.toString());
+    database.setLocationUri(SLASH.join(warehouseLocation, 
SLASH.join(namespace.levels())) + ".db");
 
 Review comment:
   Since we know that `namespace.levels()` has only one entry, this should be 
`namespace.level(0) + ".db"`  instead of using `SLASH.join`.

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