@Test(expected = MetaException.class) public void testAddPartitionsNullPartition() throws Exception { List<Partition> partitions = new ArrayList<>(); partitions.add(null); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartsNullPartition() throws Exception { List<Partition> partitions = new ArrayList<>(); partitions.add(null); client.add_partitions(partitions, false, false); }
@Test public void testAddPartsEmptyList() throws Exception { List<Partition> addedPartitions = client.add_partitions(new ArrayList<>(), false, true); Assert.assertNotNull(addedPartitions); Assert.assertTrue(addedPartitions.isEmpty()); }
@Test(expected = MetaException.class) public void testAddPartitionsEmptyTable() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition2 = buildPartition(DB_NAME, "", "2017"); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@Test(expected = InvalidObjectException.class) public void testAddPartitionsNonExistingDb() throws Exception { createTable(); Partition partition1 = buildPartition("nonexistingdb", TABLE_NAME, "2017"); Partition partition2 = buildPartition(DB_NAME, TABLE_NAME, "2016"); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsNonExistingTable() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition2 = buildPartition(DB_NAME, "nonexistingtable", "2017"); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsEmptyDb() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition2 = buildPartition("", TABLE_NAME, "2017"); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@Test(expected=MetaException.class) public void testAddPartitionsForView() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartsDuplicateInTheList() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2017"); Partition partition2 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition3 = buildPartition(DB_NAME, TABLE_NAME, "2017"); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); partitions.add(partition3); client.add_partitions(partitions, true, false); }
@Test(expected=MetaException.class) public void testAddPartitionsMorePartColInTable() throws Exception { createTable(DB_NAME, TABLE_NAME, getYearAndMonthPartCols(), null); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); List<Partition> partitions = new ArrayList<>(); partitions.add(partition); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsNullSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.setSd(null); List<Partition> partitions = new ArrayList<>(); partitions.add(partition); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsNullTable() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition2 = buildPartition(DB_NAME, TABLE_NAME, "2017"); partition2.setTableName(null); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsNullValues() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, null); partition.setValues(null); List<Partition> partitions = new ArrayList<>(); partitions.add(partition); client.add_partitions(partitions); }
@Test(expected = MetaException.class) public void testAddPartitionsNullDb() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, "2016"); Partition partition2 = buildPartition(DB_NAME, TABLE_NAME, "2017"); partition2.setDbName(null); List<Partition> partitions = new ArrayList<>(); partitions.add(partition1); partitions.add(partition2); client.add_partitions(partitions); }
@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(expected = MetaException.class) public void testAddPartitionsNullColTypeInSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.getSd().getCols().get(0).setType(null); client.add_partitions(Lists.newArrayList(partition)); }
@Test(expected = MetaException.class) public void testAddPartitionsNullColNameInSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.getSd().getCols().get(0).setName(null); client.add_partitions(Lists.newArrayList(partition)); }
@Test(expected = MetaException.class) public void testAddPartitionsEmptySerdeInfo() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.getSd().setSerdeInfo(null); client.add_partitions(Lists.newArrayList(partition)); }
@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); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd()); }
@Test public void testAddPartitionsForViewNullPartLocation() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.getSd().setLocation(null); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd().getLocation()); }