dataset.addMetadata(PARTITION_KEY, updatedMetadata); dataset.addMetadata(PARTITION_KEY, "key2", "value3"); Assert.fail("Expected not to be able to update an existing metadata entry"); } catch (DataSetException expected) { .addStringField("s", "nonexistent") .build(); dataset.addMetadata(nonexistentPartitionKey, "key2", "value3"); Assert.fail("Expected not to be able to add metadata for a nonexistent partition"); } catch (DataSetException expected) {
@Test public void testMetadataForNonexistentPartition() throws Exception { PartitionedFileSet pfs = dsFrameworkUtil.getInstance(pfsInstance); PartitionKey key = generateUniqueKey(); TransactionContext txContext = new TransactionContext(txClient, (TransactionAware) pfs); txContext.start(); try { // didn't add any partitions to the dataset, so any partition key should throw a PartitionNotFoundException pfs.addMetadata(key, "metaKey", "metaValue"); Assert.fail("Expected not to find key: " + key); } catch (PartitionNotFoundException e) { Assert.assertEquals(pfsInstance.getEntityName(), e.getPartitionedFileSetName()); Assert.assertEquals(key, e.getPartitionKey()); } finally { txContext.abort(); } }
"some/location", ImmutableMap.of("a", "b")); try { pfs.addMetadata( PartitionKey.builder().addField("i", 1).addField("l", 2L).addField("s", "a").addField("x", "x").build(), ImmutableMap.of("abc", "xyz"));