@Test public void testDropTable() throws Exception { Configuration conf = new Configuration(); String warehousePath = temp.newFolder().getAbsolutePath(); HadoopCatalog catalog = new HadoopCatalog(conf, warehousePath); TableIdentifier testTable = TableIdentifier.of("db", "ns1", "ns2", "tbl"); catalog.createTable(testTable, SCHEMA, PartitionSpec.unpartitioned()); String metaLocation = catalog.defaultWarehouseLocation(testTable); FileSystem fs = Util.getFs(new Path(metaLocation), conf); Assert.assertTrue(fs.isDirectory(new Path(metaLocation))); catalog.dropTable(testTable); Assert.assertFalse(fs.isDirectory(new Path(metaLocation))); }
@Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { throw new NoSuchTableException("Invalid identifier: %s", identifier); } Path tablePath = new Path(defaultWarehouseLocation(identifier)); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { if (purge && lastMetadata != null) { dropTableData(ops.io(), lastMetadata); } fs.delete(tablePath, true ); return true; } catch (IOException e) { throw new RuntimeIOException(e, "Failed to delete file: %s", tablePath); } }
HadoopCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { throw new NoSuchTableException("Invalid identifier: %s", identifier); } Path tablePath = new Path(defaultWarehouseLocation(identifier)); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { if (purge && lastMetadata != null) { dropTableData(ops.io(), lastMetadata); } fs.delete(tablePath, true ); return true; } catch (IOException e) { throw new RuntimeIOException(e, "Failed to delete file: %s", tablePath); } } }
HadoopCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { throw new NoSuchTableException("Invalid identifier: %s", identifier); } Path tablePath = new Path(defaultWarehouseLocation(identifier)); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { if (purge && lastMetadata != null) { dropTableData(ops.io(), lastMetadata); } fs.delete(tablePath, true ); return true; } catch (IOException e) { throw new RuntimeIOException(e, "Failed to delete file: %s", tablePath); } } HadoopCatalog(String name, Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf); }
HadoopCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { throw new NoSuchTableException("Invalid identifier: %s", identifier); } Path tablePath = new Path(defaultWarehouseLocation(identifier)); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { if (purge && lastMetadata != null) { dropTableData(ops.io(), lastMetadata); } fs.delete(tablePath, true ); return true; } catch (IOException e) { throw new RuntimeIOException(e, "Failed to delete file: %s", tablePath); } } HadoopCatalog(String name, Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf); @Override List<TableIdentifier> listTables(Namespace namespace); @Override Table createTable(
      TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties); @Override boolean dropTable(TableIdentifier identifier, boolean purge); @Override void renameTable(TableIdentifier from, TableIdentifier to); @Override void createNamespace(Namespace namespace, Map<String, String> meta); @Override List<Namespace> listNamespaces(Namespace namespace); @Override boolean dropNamespace(Namespace namespace); @Override boolean setProperties(Namespace namespace,  Map<String, String> properties); @Override boolean removeProperties(Namespace namespace,  Set<String> properties); @Override Map<String, String> loadNamespaceMetadata(Namespace namespace); @Override void close(); }
HadoopCatalog extends BaseMetastoreCatalog implements Closeable, SupportsNamespaces { @Override public boolean dropTable(TableIdentifier identifier, boolean purge) { if (!isValidIdentifier(identifier)) { throw new NoSuchTableException("Invalid identifier: %s", identifier); } Path tablePath = new Path(defaultWarehouseLocation(identifier)); TableOperations ops = newTableOps(identifier); TableMetadata lastMetadata; if (purge && ops.current() != null) { lastMetadata = ops.current(); } else { lastMetadata = null; } try { if (purge && lastMetadata != null) { dropTableData(ops.io(), lastMetadata); } fs.delete(tablePath, true ); return true; } catch (IOException e) { throw new RuntimeIOException(e, "Failed to delete file: %s", tablePath); } } HadoopCatalog(String name, Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf, String warehouseLocation);  HadoopCatalog(Configuration conf); @Override List<TableIdentifier> listTables(Namespace namespace); @Override Table createTable(
      TableIdentifier identifier, Schema schema, PartitionSpec spec, String location, Map<String, String> properties); @Override boolean dropTable(TableIdentifier identifier, boolean purge); @Override void renameTable(TableIdentifier from, TableIdentifier to); @Override void createNamespace(Namespace namespace, Map<String, String> meta); @Override List<Namespace> listNamespaces(Namespace namespace); @Override boolean dropNamespace(Namespace namespace); @Override boolean setProperties(Namespace namespace,  Map<String, String> properties); @Override boolean removeProperties(Namespace namespace,  Set<String> properties); @Override Map<String, String> loadNamespaceMetadata(Namespace namespace); @Override void close();  }