@Test(expected = InvalidOperationException.class) public void testRenamePartitionTargetAlreadyExisting() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition(DB_NAME, TABLE_NAME, oldValues.get(3), oldParts.get(2)); }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionsChangeValues() throws Exception { createTable4PartColsParts(client); List<Partition> partitions = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition p = partitions.get(3); p.setValues(Lists.newArrayList("1", "2", "3")); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(p)); }
@Test(expected = InvalidOperationException.class) public void testRenamePartitionBogusCatalogName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition("nosuch", DB_NAME, TABLE_NAME, oldValues.get(3), partToRename, null); }
@Test(expected = InvalidOperationException.class) public void testRenamePartitionNoDbName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition("", TABLE_NAME, oldValues.get(3), partToRename); }
@Test(expected = InvalidOperationException.class) public void testRenamePartitionNoTblName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition(DB_NAME, "", oldValues.get(3), partToRename); }
@Test(expected = InvalidOperationException.class) public void testRenamePartitionEmptyOldPartList() throws Exception { createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition(DB_NAME, TABLE_NAME, Lists.newArrayList(), partToRename); }
@Test(expected = InvalidOperationException.class) public void testRenamePartitionNoSuchOldPartition() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); client.renamePartition(DB_NAME, TABLE_NAME, Lists.newArrayList("1", "2", ""), partToRename); }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionsWithEnvironmentCtxChangeValues() throws Exception { createTable4PartColsParts(client); List<Partition> partitions = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition p = partitions.get(3); p.setValues(Lists.newArrayList("1", "2", "3")); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(p), new EnvironmentContext()); }
@Test public void testRenamePartitionNullTblName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); try { client.renamePartition(DB_NAME, null, oldValues.get(3), partToRename); Assert.fail("should throw"); } catch (MetaException | TProtocolException ex) { } }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionChangeValues() throws Exception { createTable4PartColsParts(client); List<Partition> partitions = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partition = partitions.get(3); partition.setValues(Lists.newArrayList("1", "2", "3")); client.alter_partition(DB_NAME, TABLE_NAME, partition); }
@Test(expected = MetaException.class) public void testRenamePartitionChangeTblName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); partToRename.setTableName(TABLE_NAME + "_2"); client.renamePartition(DB_NAME, TABLE_NAME, oldValues.get(3), partToRename); }
@Test(expected = MetaException.class) public void testRenamePartitionNullTableInPartition() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); partToRename.setTableName(null); client.renamePartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2017", "11", "27"), partToRename); }
@Test(expected = MetaException.class) public void testRenamePartitionNullDbInPartition() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); partToRename.setDbName(null); client.renamePartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2017", "11", "27"), partToRename); }
@Test(expected = MetaException.class) public void testRenamePartitionChangeDbName() throws Exception { List<List<String>> oldValues = createTable4PartColsParts(client); List<Partition> oldParts = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1); Partition partToRename = oldParts.get(3); partToRename.setValues(Lists.newArrayList("2018", "01", "16")); partToRename.setDbName(DB_NAME + "_2"); client.renamePartition(DB_NAME, TABLE_NAME, oldValues.get(3), partToRename); }
@Test(expected = MetaException.class) public void testAddPartitionSpecNullValues() throws Exception { createTable(); Partition partition = buildPartition(DB_NAME, TABLE_NAME, null); partition.setValues(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); }
public static org.apache.hadoop.hive.metastore.api.Partition toMetastoreApiPartition(Partition partition) { org.apache.hadoop.hive.metastore.api.Partition result = new org.apache.hadoop.hive.metastore.api.Partition(); result.setDbName(partition.getDatabaseName()); result.setTableName(partition.getTableName()); result.setValues(partition.getValues()); result.setSd(makeStorageDescriptor(partition.getTableName(), partition.getColumns(), partition.getStorage())); result.setParameters(partition.getParameters()); return result; }
private static Partition createPtn(Table t, List<String> pvals) { Partition ptn = new Partition(); ptn.setDbName(t.getDbName()); ptn.setTableName(t.getTableName()); ptn.setValues(pvals); return ptn; }
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); }
private void add_partition(HiveMetaStoreClient client, Table table, List<String> vals, String location) throws TException { Partition part = new Partition(); part.setDbName(table.getDbName()); part.setTableName(table.getTableName()); part.setValues(vals); part.setParameters(new HashMap<>()); part.setSd(table.getSd().deepCopy()); part.getSd().setSerdeInfo(table.getSd().getSerdeInfo()); part.getSd().setLocation(table.getSd().getLocation() + location); client.add_partition(part); }
private void addPartition(HiveMetaStoreClient client, Table table, List<String> vals, String location) throws TException { Partition part = new Partition(); part.setDbName(table.getDbName()); part.setTableName(table.getTableName()); part.setValues(vals); part.setParameters(new HashMap<String, String>()); part.setSd(table.getSd().deepCopy()); part.getSd().setSerdeInfo(table.getSd().getSerdeInfo()); part.getSd().setLocation(table.getSd().getLocation() + location); client.add_partition(part); } }