@Override public Map<String, String> getParameters() { return pSpec.getPartitions().get(index).getParameters(); }
public Object getFieldValue(_Fields field) { switch (field) { case VALUES: return getValues(); case CREATE_TIME: return getCreateTime(); case LAST_ACCESS_TIME: return getLastAccessTime(); case RELATIVE_PATH: return getRelativePath(); case PARAMETERS: return getParameters(); case PRIVILEGES: return getPrivileges(); } throw new IllegalStateException(); }
private void verifyLocations(List<Partition> origPartitions, StorageDescriptor sharedSD, List<PartitionWithoutSD> partitionWithoutSDS) { int i=0; for (Partition origPart : origPartitions) { // in case of location sharedSD has the base location and partition has relative location Assert.assertEquals("Location does not match", origPart.getSd().getLocation(), sharedSD.getLocation() + partitionWithoutSDS.get(i).getRelativePath()); Assert.assertNull("values were not requested but are still set", partitionWithoutSDS.get(i).getValues()); Assert.assertNull("Parameters were not requested but are still set", partitionWithoutSDS.get(i).getParameters()); i++; } }
@Override public Partition getCurrent() { PartitionWithoutSD partWithoutSD = pSpec.getPartitions().get(index); StorageDescriptor partSD = new StorageDescriptor(pSpec.getSd()); partSD.setLocation(partSD.getLocation() + partWithoutSD.getRelativePath()); Partition p = new Partition( partWithoutSD.getValues(), partitionSpecWithSharedSDProxy.partitionSpec.getDbName(), partitionSpecWithSharedSDProxy.partitionSpec.getTableName(), partWithoutSD.getCreateTime(), partWithoutSD.getLastAccessTime(), partSD, partWithoutSD.getParameters() ); p.setCatName(partitionSpecWithSharedSDProxy.partitionSpec.getCatName()); return p; }
@Test public void testPartitionProjectionIncludeParameters() throws Throwable { GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec .setFieldList(Arrays.asList("dbName", "tableName", "catName", "parameters", "values")); projectSpec.setIncludeParamKeyPattern(EXCLUDE_KEY_PREFIX + "%"); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull("All the partitions should be returned in sharedSD spec", partitionSpecWithSharedSD); PartitionListComposingSpec partitionListComposingSpec = response.getPartitionSpec().get(0).getPartitionList(); Assert.assertNull("Partition list composing spec should be null since all the " + "partitions are expected to be in sharedSD spec", partitionListComposingSpec); for (PartitionWithoutSD retPartion : partitionSpecWithSharedSD.getPartitions()) { Assert.assertTrue("included parameter key is not found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key1")); Assert.assertTrue("included parameter key is not found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key2")); Assert.assertEquals("Additional parameters returned other than inclusion keys", 2, retPartion.getParameters().size()); } }
@Test public void testPartitionProjectionIncludeExcludeParameters() throws Throwable { GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec .setFieldList(Arrays.asList("dbName", "tableName", "catName", "parameters", "values")); // test parameter key inclusion using setIncludeParamKeyPattern projectSpec.setIncludeParamKeyPattern(EXCLUDE_KEY_PREFIX + "%"); projectSpec.setExcludeParamKeyPattern("%key1%"); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull("All the partitions should be returned in sharedSD spec", partitionSpecWithSharedSD); PartitionListComposingSpec partitionListComposingSpec = response.getPartitionSpec().get(0).getPartitionList(); Assert.assertNull("Partition list composing spec should be null since all the " + "partitions are expected to be in sharedSD spec", partitionListComposingSpec); for (PartitionWithoutSD retPartion : partitionSpecWithSharedSD.getPartitions()) { Assert.assertFalse("excluded parameter key is found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key1")); Assert.assertTrue("included parameter key is not found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key2")); Assert.assertEquals("Additional parameters returned other than inclusion keys", 1, retPartion.getParameters().size()); } }
@Test public void testPartitionProjectionExcludeParameters() throws Throwable { GetPartitionsRequest request = getGetPartitionsRequest(); GetPartitionsProjectionSpec projectSpec = request.getProjectionSpec(); projectSpec .setFieldList(Arrays.asList("dbName", "tableName", "catName", "parameters", "values")); projectSpec.setExcludeParamKeyPattern(EXCLUDE_KEY_PREFIX + "%"); GetPartitionsResponse response = client.getPartitionsWithSpecs(request); PartitionSpecWithSharedSD partitionSpecWithSharedSD = response.getPartitionSpec().get(0).getSharedSDPartitionSpec(); Assert.assertNotNull("All the partitions should be returned in sharedSD spec", partitionSpecWithSharedSD); PartitionListComposingSpec partitionListComposingSpec = response.getPartitionSpec().get(0).getPartitionList(); Assert.assertNull("Partition list composing spec should be null", partitionListComposingSpec); for (PartitionWithoutSD retPartion : partitionSpecWithSharedSD.getPartitions()) { Assert.assertFalse("excluded parameter key is found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key1")); Assert.assertFalse("excluded parameter key is found in the response", retPartion.getParameters().containsKey(EXCLUDE_KEY_PREFIX + "key2")); } }
returnedPartitionWithoutSD.getParameters().containsKey("key1")); Assert.assertEquals("partition parameters does not contain included keys", "val1", returnedPartitionWithoutSD.getParameters().get("key1")); returnedPartitionWithoutSD.getParameters().containsKey("excludeKey1")); Assert.assertFalse("Excluded parameter key returned", returnedPartitionWithoutSD.getParameters().containsKey("excludeKey2"));
validateList(expectedVals.get(i), retPartition.getValues()); Assert.assertNull("parameters were not requested so should have been null", retPartition.getParameters());
Assert.assertEquals(origPartition.getSd().getLocation(), sharedSD.getLocation() + retPartition.getRelativePath()); validateMap(origPartition.getParameters(), retPartition.getParameters()); validateList(origPartition.getValues(), retPartition.getValues());
break; case "parameters": validateMap(origPartition.getParameters(), retPartition.getParameters()); break; case "sd.cols":
@Override public Map<String, String> getParameters() { return pSpec.getPartitions().get(index).getParameters(); }
@Override public Map<String, String> getParameters() { return pSpec.getPartitions().get(index).getParameters(); }
public Object getFieldValue(_Fields field) { switch (field) { case VALUES: return getValues(); case CREATE_TIME: return Integer.valueOf(getCreateTime()); case LAST_ACCESS_TIME: return Integer.valueOf(getLastAccessTime()); case RELATIVE_PATH: return getRelativePath(); case PARAMETERS: return getParameters(); case PRIVILEGES: return getPrivileges(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case VALUES: return getValues(); case CREATE_TIME: return Integer.valueOf(getCreateTime()); case LAST_ACCESS_TIME: return Integer.valueOf(getLastAccessTime()); case RELATIVE_PATH: return getRelativePath(); case PARAMETERS: return getParameters(); case PRIVILEGES: return getPrivileges(); } throw new IllegalStateException(); }
@Override public Partition getCurrent() { PartitionWithoutSD partWithoutSD = pSpec.getPartitions().get(index); StorageDescriptor partSD = new StorageDescriptor(pSpec.getSd()); partSD.setLocation(partSD.getLocation() + partWithoutSD.getRelativePath()); return new Partition( partWithoutSD.getValues(), partitionSpecWithSharedSDProxy.partitionSpec.getDbName(), partitionSpecWithSharedSDProxy.partitionSpec.getTableName(), partWithoutSD.getCreateTime(), partWithoutSD.getLastAccessTime(), partSD, partWithoutSD.getParameters() ); }
@Override public Partition getCurrent() { PartitionWithoutSD partWithoutSD = pSpec.getPartitions().get(index); StorageDescriptor partSD = new StorageDescriptor(pSpec.getSd()); partSD.setLocation(partSD.getLocation() + partWithoutSD.getRelativePath()); return new Partition( partWithoutSD.getValues(), partitionSpecWithSharedSDProxy.partitionSpec.getDbName(), partitionSpecWithSharedSDProxy.partitionSpec.getTableName(), partWithoutSD.getCreateTime(), partWithoutSD.getLastAccessTime(), partSD, partWithoutSD.getParameters() ); }