Search in sources :

Example 1 with NamespaceNotEmptyException

use of org.apache.iceberg.exceptions.NamespaceNotEmptyException in project hive by apache.

the class HiveCatalog method dropNamespace.

@Override
public boolean dropNamespace(Namespace namespace) {
    if (!isValidateNamespace(namespace)) {
        return false;
    }
    try {
        clients.run(client -> {
            client.dropDatabase(namespace.level(0), false, /* deleteData */
            false, /* ignoreUnknownDb */
            false);
            return null;
        });
        LOG.info("Dropped namespace: {}", namespace);
        return true;
    } catch (InvalidOperationException e) {
        throw new NamespaceNotEmptyException(e, "Namespace %s is not empty. One or more tables exist.", namespace);
    } catch (NoSuchObjectException e) {
        return false;
    } catch (TException e) {
        throw new RuntimeException("Failed to drop namespace " + namespace + " in Hive Matastore", e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException("Interrupted in call to drop dropDatabase(name) " + namespace + " in Hive Matastore", e);
    }
}
Also used : TException(org.apache.thrift.TException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) NamespaceNotEmptyException(org.apache.iceberg.exceptions.NamespaceNotEmptyException) NoSuchObjectException(org.apache.hadoop.hive.metastore.api.NoSuchObjectException)

Aggregations

InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)1 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)1 NamespaceNotEmptyException (org.apache.iceberg.exceptions.NamespaceNotEmptyException)1 TException (org.apache.thrift.TException)1