electrum commented on a change in pull request #240: Add HiveCatalog
implementation
URL: https://github.com/apache/incubator-iceberg/pull/240#discussion_r298692031
##########
File path: hive/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
##########
@@ -0,0 +1,119 @@
+package org.apache.iceberg.hive;
+
+import java.io.Closeable;
+import java.util.Map;
+import com.google.common.base.Preconditions;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.iceberg.BaseMetastoreCatalog;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.TableOperations;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.thrift.TException;
+
+public class HiveCatalog extends BaseMetastoreCatalog implements Closeable {
+
+ private final HiveClientPool clients;
+
+ public HiveCatalog(Configuration conf) {
+ super(conf);
+ this.clients = new HiveClientPool(2, conf);
+ }
+
+ @Override
+ public org.apache.iceberg.Table createTable(
+ TableIdentifier identifier, Schema schema, PartitionSpec spec, String
location, Map<String, String> properties) {
+ Preconditions.checkArgument(identifier.namespace().levels().length == 1,
+ "Missing database in table identifier: %s", identifier);
+ return super.createTable(identifier, schema, spec, location, properties);
+ }
+
+ @Override
+ public org.apache.iceberg.Table loadTable(TableIdentifier identifier) {
+ Preconditions.checkArgument(identifier.namespace().levels().length == 1,
+ "Missing database in table identifier: %s", identifier);
+ return super.loadTable(identifier);
+ }
+
+ @Override
+ public boolean dropTable(TableIdentifier identifier) {
+ Preconditions.checkArgument(identifier.namespace().levels().length == 1,
+ "Missing database in table identifier: %s", identifier);
+ String database = identifier.namespace().level(0);
+
+ try {
+ clients.run(client -> {
+ client.dropTable(database, identifier.name());
Review comment:
This delegates to the longer variant with `dropTable=true`. We might want to
call the other version explicitly, if that is not the intended behavior. Also,
we should consider how this affects earlier created tables that had a table
type of `ICEBERG` rather than `EXTERNAL_TABLE`.
----------------------------------------------------------------
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]