public Partition addToTable(IMetaStoreClient client, Configuration conf) throws TException { Partition p = build(conf); client.add_partition(p); return p; } }
@Test(expected = InvalidObjectException.class) public void testAddPartitionNonExistingTable() throws Exception { Partition partition = buildPartition(DB_NAME, "nonexistingtable", DEFAULT_YEAR_VALUE); client.add_partition(partition); }
@Test(expected = AlreadyExistsException.class) public void testAddPartitionAlreadyExists() throws Exception { createTable(); Partition partition1 = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); Partition partition2 = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); client.add_partition(partition1); client.add_partition(partition2); }
@Test public void createOnPartitionTable() throws Exception { helper.createPartitionIfNotExists(PARTITIONED_VALUES); verify(mockClient).add_partition(partitionCaptor.capture()); Partition actual = partitionCaptor.getValue(); assertThat(actual.getSd().getLocation(), is(PARTITION_LOCATION)); assertThat(actual.getValues(), is(PARTITIONED_VALUES)); }
@Test(expected = MetaException.class) public void testAddPartitionTooManyValues() throws Exception { createTable(); Partition partition = buildPartition(Lists.newArrayList(DEFAULT_YEAR_VALUE, "march"), getYearAndMonthPartCols(), 1); client.add_partition(partition); }
@Test(expected = MetaException.class) public void testAddPartitionForView() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); client.add_partition(partition); }
private void addPartition(IMetaStoreClient client, Table table, List<String> values) throws TException { PartitionBuilder partitionBuilder = new PartitionBuilder().inTable(table); values.forEach(val -> partitionBuilder.addValue(val)); client.add_partition(partitionBuilder.build(metaStore.getConf())); }
private void addPartition(IMetaStoreClient client, Table table, List<String> values) throws TException { PartitionBuilder partitionBuilder = new PartitionBuilder().inTable(table); values.forEach(val -> partitionBuilder.addValue(val)); client.add_partition(partitionBuilder.build(metaStore.getConf())); }
@Test(expected = MetaException.class) public void testAddPartitionNullSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.setSd(null); client.add_partition(partition); }
@Test(expected = MetaException.class) public void testAddPartitionMorePartColInTable() throws Exception { createTable(DB_NAME, TABLE_NAME, getYearAndMonthPartCols(), null); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); client.add_partition(partition); }
@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)); }
private Partition createPartition(Table table, List<String> values, String location) throws Exception { Partition partition = buildPartition(table, values, location); client.add_partition(partition); return client.getPartition(DB_NAME, table.getTableName(), partition.getValues()); }
@Test(expected = MetaException.class) public void testExchangePartitionPartAlreadyExists() throws Exception { Partition partition = buildPartition(destTable, Lists.newArrayList("2017", "march", "22"), null); client.add_partition(partition); Map<String, String> partitionSpecs = getPartitionSpec(partitions[1]); client.exchange_partition(partitionSpecs, DB_NAME, sourceTable.getTableName(), DB_NAME, destTable.getTableName()); }
@Test(expected = MetaException.class) public void testAddPartitionNullColNameInSd() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.getSd().getCols().get(0).setName(null); client.add_partition(partition); }
@Test(expected = MetaException.class) public void testAddPartitionEmptySerdeInfo() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE); partition.getSd().setSerdeInfo(null); client.add_partition(partition); }
protected Partition newPartition(Table t, String value, List<Order> sortCols) throws Exception { Partition part = new Partition(); part.addToValues(value); part.setDbName(t.getDbName()); part.setTableName(t.getTableName()); part.setSd(newStorageDescriptor(getLocation(t.getTableName(), value), sortCols)); part.setParameters(new HashMap<String, String>()); ms.add_partition(part); return part; }
@Test public void testAddPartitionNullLocationInTableToo() throws Exception { createTable(DB_NAME, TABLE_NAME, null); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null); client.add_partition(partition); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2017"); Assert.assertEquals( metaStore.getWarehouseRoot() + "/test_partition_db.db/test_partition_table/year=2017", part.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(part.getSd().getLocation()))); }
@Test public void testAddPartitionEmptyLocation() throws Exception { createTable(DB_NAME, TABLE_NAME, metaStore.getWarehouseRoot() + "/addparttest3"); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, ""); client.add_partition(partition); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2017"); Assert.assertEquals(metaStore.getWarehouseRoot() + "/addparttest3/year=2017", part.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(part.getSd().getLocation()))); }
@Test public void testAddPartitionNullLocation() throws Exception { createTable(DB_NAME, TABLE_NAME, metaStore.getWarehouseRoot() + "/addparttest2"); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null); client.add_partition(partition); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2017"); Assert.assertEquals(metaStore.getWarehouseRoot() + "/addparttest2/year=2017", part.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(part.getSd().getLocation()))); }
private static void addPartition(IMetaStoreClient client, Table tbl , List<String> partValues) throws IOException, TException { Partition part = new Partition(); part.setDbName(tbl.getDbName()); part.setTableName(tbl.getTableName()); StorageDescriptor sd = new StorageDescriptor(tbl.getSd()); sd.setLocation(sd.getLocation() + Path.SEPARATOR + makePartPath(tbl.getPartitionKeys(), partValues)); part.setSd(sd); part.setValues(partValues); client.add_partition(part); }