/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op * * @param tableName * table to drop * @throws HiveException * thrown if the drop fails */ public void dropTable(String tableName) throws HiveException { dropTable(tableName, false); }
/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op * * @param dbName * database where the table lives * @param tableName * table to drop * @throws HiveException * thrown if the drop fails */ public void dropTable(String dbName, String tableName) throws HiveException { dropTable(dbName, tableName, true, true, false); }
/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op * * @param tableName * table to drop * @throws HiveException * thrown if the drop fails */ public void dropTable(String tableName) throws HiveException { dropTable(tableName, false); }
/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op * * @param dbName * database where the table lives * @param tableName * table to drop * @throws HiveException * thrown if the drop fails */ public void dropTable(String dbName, String tableName) throws HiveException { dropTable(dbName, tableName, true, true, false); }
/** * Drops the table. * * @param dbName * @param tableName * @param deleteData * deletes the underlying data along with metadata * @param ignoreUnknownTab * an exception is thrown if this is false and the table doesn't exist * @throws HiveException */ public void dropTable(String dbName, String tableName, boolean deleteData, boolean ignoreUnknownTab) throws HiveException { dropTable(dbName, tableName, deleteData, ignoreUnknownTab, false); }
/** * Drops the table. * * @param dbName * @param tableName * @param deleteData * deletes the underlying data along with metadata * @param ignoreUnknownTab * an exception is thrown if this is false and the table doesn't exist * @throws HiveException */ public void dropTable(String dbName, String tableName, boolean deleteData, boolean ignoreUnknownTab) throws HiveException { dropTable(dbName, tableName, deleteData, ignoreUnknownTab, false); }
/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op. If ifPurge option is specified it is passed to the * hdfs command that removes table data from warehouse to make it skip trash. * * @param tableName * table to drop * @param ifPurge * completely purge the table (skipping trash) while removing data from warehouse * @throws HiveException * thrown if the drop fails */ public void dropTable(String tableName, boolean ifPurge) throws HiveException { String[] names = Utilities.getDbTableName(tableName); dropTable(names[0], names[1], true, true, ifPurge); }
/** * Drops table along with the data in it. If the table doesn't exist then it * is a no-op. If ifPurge option is specified it is passed to the * hdfs command that removes table data from warehouse to make it skip trash. * * @param tableName * table to drop * @param ifPurge * completely purge the table (skipping trash) while removing data from warehouse * @throws HiveException * thrown if the drop fails */ public void dropTable(String tableName, boolean ifPurge) throws HiveException { String[] names = Utilities.getDbTableName(tableName); dropTable(names[0], names[1], true, true, ifPurge); }
private void cleanUpTableQuietly(String dbName, String tableName) { try { hm.dropTable(dbName, tableName, true, true, true); } catch(Exception exception) { fail("Unexpected exception: " + StringUtils.stringifyException(exception)); } }
@AfterClass public static void deInit() throws Exception { Hive h = Hive.get(conf); h.dropTable("foo"); }
private Table createPartitionedTable(String dbName, String tableName) throws Exception { try { hm.dropTable(dbName, tableName); hm.createTable(tableName, Arrays.asList("key", "value"), // Data columns. Arrays.asList("ds", "hr"), // Partition columns. TextInputFormat.class, HiveIgnoreKeyTextOutputFormat.class); return hm.getTable(dbName, tableName); } catch (Exception exception) { fail("Unable to drop and create table " + StatsUtils.getFullyQualifiedTableName(dbName, tableName) + " because " + StringUtils.stringifyException(exception)); throw exception; } }
String tableName = "table_for_testpartition"; try { hm.dropTable(Warehouse.DEFAULT_DATABASE_NAME, tableName); } catch (HiveException e) { System.err.println(StringUtils.stringifyException(e)); assertTrue("Unable to create parition for table: " + tableName, false); hm.dropTable(Warehouse.DEFAULT_DATABASE_NAME, tableName); } catch (Throwable e) { System.err.println(StringUtils.stringifyException(e));
/** * Removes all databases and tables from the metastore */ public static void cleanupHMS(Hive hive, Warehouse wh, FsPermission defaultPerm) throws HiveException, MetaException, NoSuchObjectException { for (String dbName : hive.getAllDatabases()) { if (dbName.equals("default")) { continue; } try { Path path = getDbPath(hive, wh, dbName); FileSystem whFs = path.getFileSystem(hive.getConf()); whFs.setPermission(path, defaultPerm); } catch (IOException ex) { //ignore } hive.dropDatabase(dbName, true, true, true); } //clean tables in default db for (String tablename : hive.getAllTables("default")) { hive.dropTable("default", tablename, true, true); } }
@Test public void testDataDeletion() throws HiveException, IOException, TException { Database db = new Database(); db.setName(dbName); hive.createDatabase(db); Table table = new Table(dbName, tableName); table.setDbName(dbName); table.setInputFormatClass(TextInputFormat.class); table.setOutputFormatClass(HiveIgnoreKeyTextOutputFormat.class); table.setPartCols(partCols); hive.createTable(table); table = hive.getTable(dbName, tableName); Path fakeTable = table.getPath().getParent().suffix( Path.SEPARATOR + "faketable"); fs = fakeTable.getFileSystem(hive.getConf()); fs.mkdirs(fakeTable); fs.deleteOnExit(fakeTable); Path fakePart = new Path(table.getDataLocation().toString(), "fakepartition=fakevalue"); fs.mkdirs(fakePart); fs.deleteOnExit(fakePart); hive.dropTable(dbName, tableName, true, true); assertFalse(fs.exists(fakePart)); hive.dropDatabase(dbName); assertFalse(fs.exists(fakeTable)); }
Path pathglob = trash1.suffix("*");; FileStatus before[] = fs.globStatus(pathglob); hm.dropTable(dbName, ts.get(0)); assertFalse(fs.exists(path1)); FileStatus after[] = fs.globStatus(pathglob); pathglob = trash2.suffix("*"); before = fs.globStatus(pathglob); hm.dropTable(dbName, ts.get(1), true, true, true); // deleteData, ignoreUnknownTable, ifPurge assertFalse(fs.exists(path2)); after = fs.globStatus(pathglob); hm.dropTable(dbName, tableName); assertFalse(fs.exists(table.getPath()));
hive.dropTable(dbName, tableName, true, true); hive.createTable(table); result = new CheckResult();
hm.dropTable(dbName, tableName); trashSizeAfterDrop = getTrashContents().length;