@Test(expected = MetaException.class) public void testListPartitionNamesByValuesNoPartVals() throws Exception { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, TABLE_NAME, Lists.newArrayList(), (short)-1); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesByValuesNoDbName() throws Exception { createTable4PartColsParts(client); client.listPartitionNames("", TABLE_NAME, Lists.newArrayList("2017"), (short)-1); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesByValuesNoTblName() throws Exception { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, "", Lists.newArrayList("2017"), (short)-1); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesByValuesNoDb() throws Exception { client.dropDatabase(DB_NAME); client.listPartitionNames(DB_NAME, TABLE_NAME, Lists.newArrayList("2017"), (short)-1); }
@Test(expected = NoSuchObjectException.class) public void listPartitionNamesPartialValsBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, Collections.singletonList("a0"), -1); }
@Test(expected = MetaException.class) public void testListPartitionNamesByValuesTooManyVals() throws Exception { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, TABLE_NAME, Lists.newArrayList("1", "2", "3", "4"), (short)-1); }
@Test public void testListPartitionNamesByValuesMaxPartCountUnlimited() throws Exception { List<List<String>> testValues = createTable4PartColsParts(client); //TODO: due to value 101 this probably should throw an exception List<String> partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, Lists.newArrayList("2017"), (short) 101); assertCorrectPartitionNames(partitionNames, testValues.subList(2, 4), Lists.newArrayList("yyyy", "mm", "dd")); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesNoDbName() throws Exception { createTable4PartColsParts(client); client.listPartitionNames("", TABLE_NAME, (short)-1); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesNoTblName() throws Exception { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, "", (short)-1); }
@Test(expected = MetaException.class) public void testListPartitionNamesByValuesNullValues() throws Exception { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, TABLE_NAME, (List<String>)null, (short)-1); }
@Test(expected = NoSuchObjectException.class) public void testListPartitionNamesNoDb() throws Exception { client.dropDatabase(DB_NAME); client.listPartitionNames(DB_NAME, TABLE_NAME, (short)-1); }
@Test(expected = NoSuchObjectException.class) public void listPartitionNamesBogusCatalog() throws TException { createTable3PartCols1Part(client); client.listPartitionNames("bogus", DB_NAME, TABLE_NAME, -1); }
private void verifyPartitionNames(Table table, List<String> expectedPartNames) throws Exception { List<String> partitionNames = client.listPartitionNames(table.getDbName(), table.getTableName(), (short) -1); Assert.assertEquals(expectedPartNames.size(), partitionNames.size()); Assert.assertTrue(partitionNames.containsAll(expectedPartNames)); } }
@Test public void testListPartitionNamesByValuesNullTblName() throws Exception { try { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, null, Lists.newArrayList("2017"), (short)-1); fail("Should have thrown exception"); } catch (NullPointerException | TTransportException e) { //TODO: should not throw different exceptions for different HMS deployment types } }
@Test public void testListPartitionNamesByValuesNullDbName() throws Exception { try { createTable4PartColsParts(client); client.listPartitionNames(null, TABLE_NAME, Lists.newArrayList("2017"), (short) -1); fail("Should have thrown exception"); } catch (NullPointerException | TTransportException e) { //TODO: should not throw different exceptions for different HMS deployment types } }
@Test public void testListPartitionNamesNullTblName() throws Exception { try { createTable4PartColsParts(client); client.listPartitionNames(DB_NAME, (String)null, (short)-1); fail("Should have thrown exception"); } catch (NullPointerException | TTransportException e) { //TODO: should not throw different exceptions for different HMS deployment types } }
@Test public void testAddPartitionsEmptyValue() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, ""); List<Partition> partitions = new ArrayList<>(); partitions.add(partition); client.add_partitions(partitions); List<String> partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, MAX); Assert.assertNotNull(partitionNames); Assert.assertTrue(partitionNames.size() == 1); Assert.assertEquals("year=__HIVE_DEFAULT_PARTITION__", partitionNames.get(0)); }
@Test public void testListPartitionNamesNullDbName() throws Exception { try { createTable4PartColsParts(client); client.listPartitionNames(null, TABLE_NAME, (short)-1); fail("Should have thrown exception"); } catch (NullPointerException | TTransportException e) { //TODO: should not throw different exceptions for different HMS deployment types } }
@Test public void testAddPartitionEmptyValue() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, ""); client.add_partition(partition); List<String> partitionNames = client.listPartitionNames(DB_NAME, TABLE_NAME, (short) 10); Assert.assertNotNull(partitionNames); Assert.assertTrue(partitionNames.size() == 1); Assert.assertEquals("year=__HIVE_DEFAULT_PARTITION__", partitionNames.get(0)); }
@Test public void truncateTableBogusCatalog() throws TException { try { List<String> partNames = client.listPartitionNames(partitionedTable.getDbName(), partitionedTable.getTableName(), (short) -1); client.truncateTable("nosuch", partitionedTable.getDbName(), partitionedTable.getTableName(), partNames); Assert.fail(); // For reasons I don't understand and am too lazy to debug at the moment the // NoSuchObjectException gets swallowed by a TApplicationException in remote mode. } catch (TApplicationException|NoSuchObjectException e) { //NOP } }