private PartitionWithoutSD buildPartitionWithoutSD(List<String> values, int index) throws MetaException { PartitionWithoutSD partition = new PartitionWithoutSD(); partition.setCreateTime(DEFAULT_CREATE_TIME); partition.setLastAccessTime(DEFAULT_CREATE_TIME); partition.setValues(values); Map<String, String> parameters = new HashMap<>(); parameters.put(DEFAULT_PARAM_KEY + index, DEFAULT_PARAM_VALUE + index); partition.setParameters(parameters); partition.setRelativePath("partwithoutsd" + index); return partition; }
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(); }
case VALUES: if (value == null) { unsetValues(); } else { setValues((List<String>)value); unsetCreateTime(); } else { setCreateTime((Integer)value); unsetLastAccessTime(); } else { setLastAccessTime((Integer)value); unsetRelativePath(); } else { setRelativePath((String)value); unsetParameters(); } else { setParameters((Map<String,String>)value); unsetPrivileges(); } else { setPrivileges((PrincipalPrivilegeSet)value);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, PartitionSpecWithSharedSD struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list265 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.partitions = new ArrayList<PartitionWithoutSD>(_list265.size); PartitionWithoutSD _elem266; for (int _i267 = 0; _i267 < _list265.size; ++_i267) { _elem266 = new PartitionWithoutSD(); _elem266.read(iprot); struct.partitions.add(_elem266); } } struct.setPartitionsIsSet(true); } if (incoming.get(1)) { struct.sd = new StorageDescriptor(); struct.sd.read(iprot); struct.setSdIsSet(true); } } }
Assert.assertEquals(String.format("Location returned for Partition %d is not correct", i), origPartition.getSd().getLocation(), sharedSD.getLocation() + returnedPartitionWithoutSD.getRelativePath()); Assert.assertTrue("createTime was request but is not set", returnedPartitionWithoutSD.isSetCreateTime()); Assert.assertTrue("Partition parameters were requested but are not set", returnedPartitionWithoutSD.isSetParameters()); 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")); List<String> returnedVals = returnedPartitionWithoutSD.getValues(); List<String> actualVals = origPartition.getValues(); for (int j = 0; j < actualVals.size(); j++) {
@Test public void testAddPartitionSpecWithSharedSDEmptyValue() throws Exception { Table table = createTable(); PartitionWithoutSD partition = new PartitionWithoutSD(); partition.setRelativePath("addpartspectest"); partition.setValues(Lists.newArrayList("")); String location = table.getSd().getLocation() + "/nullValueTest/"; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location)); client.add_partitions_pspec(partitionSpecProxy); 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)); }
public PartitionWithoutSD deepCopy() { return new PartitionWithoutSD(this); }
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++; } }
@Test(expected=MetaException.class) public void testAddPartitionSpecWithSharedSDNoValue() throws Exception { Table table = createTable(); PartitionWithoutSD partition = new PartitionWithoutSD(); partition.setRelativePath("addpartspectest"); String location = table.getSd().getLocation() + "/nullValueTest/"; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location)); client.add_partitions_pspec(partitionSpecProxy); }
assertThat(partitions.size(), is(1)); PartitionWithoutSD partition = partitions.get(0); assertThat(partition.getRelativePath(), is((String)null)); assertThat(partition.getValues(), is(Collections.singletonList("val1")));
@Test(expected = MetaException.class) public void testAddPartitionSpecWithSharedSDNullLocation() throws Exception { createTable(); PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0); partition.setRelativePath("year2002"); String location = null; PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), buildSD(location)); client.add_partitions_pspec(partitionSpecProxy); }
Assert.assertEquals(2, retPartition.getValuesSize()); validateList(expectedVals.get(i), retPartition.getValues()); Assert.assertNull("parameters were not requested so should have been null", retPartition.getParameters());
@Override public Map<String, String> getParameters() { return pSpec.getPartitions().get(index).getParameters(); }
@Override public String getLocation() { return pSpec.getSd().getLocation() + pSpec.getPartitions().get(index).getRelativePath(); }
@Override public void setCreateTime(long time) { pSpec.getPartitions().get(index).setCreateTime((int)time); }
@Override public void setParameters(Map<String, String> parameters) { pSpec.getPartitions().get(index).setParameters(parameters); }
switch (projectedField) { case "values": validateList(origPartition.getValues(), retPartition.getValues()); break; case "parameters": validateMap(origPartition.getParameters(), retPartition.getParameters()); break; case "sd.cols":
case VALUES: if (value == null) { unsetValues(); } else { setValues((List<String>)value); unsetCreateTime(); } else { setCreateTime((Integer)value); unsetLastAccessTime(); } else { setLastAccessTime((Integer)value); unsetRelativePath(); } else { setRelativePath((String)value); unsetParameters(); } else { setParameters((Map<String,String>)value); unsetPrivileges(); } else { setPrivileges((PrincipalPrivilegeSet)value);
for (int _i262 = 0; _i262 < _list260.size; ++_i262) _elem261 = new PartitionWithoutSD(); _elem261.read(iprot); struct.partitions.add(_elem261);
/** * Performs a deep copy on <i>other</i>. */ public PartitionSpecWithSharedSD(PartitionSpecWithSharedSD other) { if (other.isSetPartitions()) { List<PartitionWithoutSD> __this__partitions = new ArrayList<PartitionWithoutSD>(other.partitions.size()); for (PartitionWithoutSD other_element : other.partitions) { __this__partitions.add(new PartitionWithoutSD(other_element)); } this.partitions = __this__partitions; } if (other.isSetSd()) { this.sd = new StorageDescriptor(other.sd); } }