@Test(expected = AlreadyExistsException.class) public void testCreateTableAlreadyExists() throws Exception { Table table = testTables[0]; table.unsetId(); client.createTable(table); }
tbl.getTTable().unsetId();
@Test public void testDropTableCaseInsensitive() throws Exception { Table table = testTables[0]; // Test in upper case client.dropTable(table.getDbName().toUpperCase(), table.getTableName().toUpperCase()); try { client.getTable(table.getDbName(), table.getTableName()); Assert.fail("Expected a NoSuchObjectException to be thrown"); } catch (NoSuchObjectException exception) { // Expected exception } table.unsetId(); // Test in mixed case client.createTable(table); client.dropTable("DeFaUlt", "TeST_tAbLE"); try { client.getTable(table.getDbName(), table.getTableName()); Assert.fail("Expected a NoSuchObjectException to be thrown"); } catch (NoSuchObjectException exception) { // Expected exception } }
table.getTTable().unsetId();
tbl.unsetId();
@Test public void testDropTableDeleteDir() throws Exception { Table table = testTables[0]; Partition externalPartition = client.getPartition(partitionedTable.getDbName(), partitionedTable.getTableName(), "test_part_col=a2"); client.dropTable(table.getDbName(), table.getTableName(), true, false); Assert.assertFalse("Table path should be removed", metaStore.isPathExists(new Path(table.getSd().getLocation()))); table.unsetId(); client.createTable(table); client.dropTable(table.getDbName(), table.getTableName(), false, false); Assert.assertTrue("Table path should be kept", metaStore.isPathExists(new Path(table.getSd().getLocation()))); // Drop table with partitions client.dropTable(partitionedTable.getDbName(), partitionedTable.getTableName(), true, false); Assert.assertFalse("Table path should be removed", metaStore.isPathExists(new Path(partitionedTable.getSd().getLocation()))); Assert.assertFalse("Extra partition path should be removed", metaStore.isPathExists(new Path(externalPartition.getSd().getLocation()))); }
@Test public void testAlterTable() throws Exception { Table originalTable = testTables[2]; String originalTableName = originalTable.getTableName(); String originalDatabase = originalTable.getDbName(); Table newTable = getTableWithAllParametersSet(); newTable.setTableName(originalTableName); newTable.setDbName(originalDatabase); // Partition keys can not be set, but getTableWithAllParametersSet is added one, so remove for // this test newTable.setPartitionKeys(originalTable.getPartitionKeys()); client.alter_table(originalDatabase, originalTableName, newTable); Table alteredTable = client.getTable(originalDatabase, originalTableName); // The extra parameters will be added on server side, so check that the required ones are // present for(String key: newTable.getParameters().keySet()) { Assert.assertEquals("parameters are present", newTable.getParameters().get(key), alteredTable.getParameters().get(key)); } // The parameters are checked manually, so do not check them newTable.setParameters(alteredTable.getParameters()); // Some of the data is set on the server side, so reset those newTable.setCreateTime(alteredTable.getCreateTime()); newTable.setCreationMetadata(alteredTable.getCreationMetadata()); newTable.setWriteId(alteredTable.getWriteId()); Assert.assertTrue(alteredTable.isSetId()); alteredTable.unsetId(); Assert.assertEquals("The table data should be the same", newTable, alteredTable); }
private Table createTestTable() throws HiveException, AlreadyExistsException { Database db = new Database(); db.setName(dbName); hive.createDatabase(db, true); 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); Assert.assertTrue(table.getTTable().isSetId()); table.getTTable().unsetId(); for (Map<String, String> partSpec : parts) { hive.createPartition(table, partSpec); } return table; }
tbl2.unsetId(); client.createTable(tbl2); if (isThriftClient) {
Table table = hmsc.getTable(dbName, tableName); Assert.assertTrue(table.isSetId()); table.unsetId(); populatePartitions(hmsc, table, Arrays.asList("isLocatedInTablePath", "isLocatedOutsideTablePath"));
case ID: if (value == null) { unsetId(); } else { setId((Long)value);