@Test(expected = MetaException.class) public void testAddPartitionSpecNullPart() throws Exception { createTable(); List<Partition> partitions = new ArrayList<>(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); Partition partition2 = null; partitions.add(partition1); partitions.add(partition2); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions); client.add_partitions_pspec(partitionSpecProxy); }
@Test public void testAddPartitionSpecEmptyPartList() throws Exception { createTable(); List<Partition> partitions = new ArrayList<>(); PartitionSpecProxy partitionSpec = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions); client.add_partitions_pspec(partitionSpec); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNullPartList() throws Exception { createTable(); List<Partition> partitions = null; PartitionSpecProxy partitionSpec = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions); client.add_partitions_pspec(partitionSpec); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNoTable() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, null, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = InvalidObjectException.class) public void testAddPartitionSpecEmptyDB() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec("", TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = InvalidObjectException.class) public void testAddPartitionSpecNonExistingDB() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec("nonexistingdb", TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNoDB() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(null, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = InvalidObjectException.class) public void testAddPartitionSpecEmptyTable() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, "", null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = MetaException.class) public void testAddPartitionSpecMoreValues() throws Exception { createTable(); Partition partition = buildPartition(Lists.newArrayList("2017", "march"), getYearAndMonthPartCols(), 1); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = InvalidObjectException.class) public void testAddPartitionSpecNonExistingTable() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, "nonexistingtable", null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNullSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.setSd(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNoDBAndTableInPartition() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.setDbName(null); partition.setTableName(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected = MetaException.class) public void testAddPartitionSpecWithSharedSDInvalidSD() throws Exception { Table table = createTable(); PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0); partition.setRelativePath("year2002"); StorageDescriptor sd = new StorageDescriptor(); sd.setLocation(table.getSd().getLocation() + "/nullLocationTest/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), sd); client.add_partitions_pspec(partitionSpecProxy); }
@Test(expected=MetaException.class) public void testAddPartitionSpecWithSharedSDNoValue() throws Exception { Table table = createTable(); PartitionWithoutSD partition = new PartitionWithoutSD(); partition.setRelativePath("addpartspectest"); String location = table.getSd().getLocation() + "/nullValueTest/"; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location)); client.add_partitions_pspec(partitionSpecProxy); }
@Test public void testAddPartitionsForViewNullPartSd() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.setSd(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, tableName, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd()); }
@Test public void testAddPartitionSpecWithSharedSDChangeRootPath() throws Exception { Table table = createTable(); String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/"; String rootPath1 = table.getSd().getLocation() + "/someotherpath/"; PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2014"), 0); PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(rootPath)); partitionSpecProxy.setRootLocation(rootPath1); client.add_partitions_pspec(partitionSpecProxy); Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2014")); Assert.assertEquals(rootPath1 + "partwithoutsd0", resultPart.getSd().getLocation()); }
@Test public void testAddPartitionSpecSetRootPath() throws Exception { Table table = createTable(); String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/"; String rootPath1 = table.getSd().getLocation() + "/someotherpath/"; Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath + "part2007/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath1, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2007")); Assert.assertEquals(rootPath + "part2007", resultPart.getSd().getLocation()); }
@Test public void testAddPartitionSpecNullLocation() throws Exception { Table table = createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList(DEFAULT_YEAR_VALUE)); Assert.assertEquals(table.getSd().getLocation() + "/year=2017", resultPart.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(resultPart.getSd().getLocation()))); }
@Test public void testAddPartitionSpecChangeRootPath() throws Exception { Table table = createTable(); String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/"; String rootPath1 = table.getSd().getLocation() + "/someotherpath/"; Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath + "part2007/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, Lists.newArrayList(partition)); partitionSpecProxy.setRootLocation(rootPath1); client.add_partitions_pspec(partitionSpecProxy); Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2007")); Assert.assertEquals(rootPath1 + "part2007", resultPart.getSd().getLocation()); }
@Test(expected = MetaException.class) public void testAddPartitionSpecChangeRootPathDiffInSd() throws Exception { Table table = createTable(); String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/"; String rootPath1 = table.getSd().getLocation() + "/addPartSdPath/"; String rootPath2 = table.getSd().getLocation() + "/someotherpath/"; Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath1 + "part2007/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, Lists.newArrayList(partition)); partitionSpecProxy.setRootLocation(rootPath2); client.add_partitions_pspec(partitionSpecProxy); }