public void setFieldValue(_Fields field, Object value) { switch (field) { case PARTITIONS: if (value == null) { unsetPartitions(); } else { setPartitions((List<PartitionWithoutSD>)value); } break; case SD: if (value == null) { unsetSd(); } else { setSd((StorageDescriptor)value); } break; } }
private PartitionSpecProxy buildPartitionSpecWithSharedSD(List<PartitionWithoutSD> partitions, StorageDescriptor sd) throws MetaException { PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME); partitionSpec.setTableName(TABLE_NAME); PartitionSpecWithSharedSD partitionList = new PartitionSpecWithSharedSD(); partitionList.setPartitions(partitions); partitionList.setSd(sd); partitionSpec.setSharedSDPartitionSpec(partitionList); return PartitionSpecProxy.Factory.get(partitionSpec); }
@Test public void testAddPartitionSpecBothTypeSet() throws Exception { Table table = createTable(); Partition partition = buildPartition(Lists.newArrayList("2013"), getYearPartCol(), 1); PartitionWithoutSD partitionWithoutSD = buildPartitionWithoutSD(Lists.newArrayList("2014"), 0); PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME); partitionSpec.setTableName(TABLE_NAME); PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec(); partitionListComposingSpec.setPartitions(Lists.newArrayList(partition)); partitionSpec.setPartitionList(partitionListComposingSpec); PartitionSpecWithSharedSD partitionSpecWithSharedSD = new PartitionSpecWithSharedSD(); partitionSpecWithSharedSD.setPartitions(Lists.newArrayList(partitionWithoutSD)); partitionSpecWithSharedSD.setSd(buildSD(table.getSd().getLocation() + "/sharedSDTest/")); partitionSpec.setSharedSDPartitionSpec(partitionSpecWithSharedSD); PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partitionSpec); 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=2013", partitionNames.get(0)); }
private PartitionSpecProxy buildPartitionSpec(List<Partition> partitions, List<PartitionWithoutSD> partitionsWithoutSD) throws MetaException { List<PartitionSpec> partitionSpecs = new ArrayList<>(); PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME); partitionSpec.setTableName(TABLE_NAME); PartitionListComposingSpec partitionListComposingSpec = new PartitionListComposingSpec(); partitionListComposingSpec.setPartitions(partitions); partitionSpec.setPartitionList(partitionListComposingSpec); PartitionSpec partitionSpecSharedSD = new PartitionSpec(); partitionSpecSharedSD.setDbName(DB_NAME); partitionSpecSharedSD.setTableName(TABLE_NAME); PartitionSpecWithSharedSD partitionSpecWithSharedSD = new PartitionSpecWithSharedSD(); partitionSpecWithSharedSD.setPartitions(partitionsWithoutSD); partitionSpecWithSharedSD .setSd(buildSD(metaStore.getWarehouseRoot() + "/" + TABLE_NAME + "/sharedSDTest/")); partitionSpecSharedSD.setSharedSDPartitionSpec(partitionSpecWithSharedSD); partitionSpecs.add(partitionSpec); partitionSpecs.add(partitionSpecSharedSD); return PartitionSpecProxy.Factory.get(partitionSpecs); }
/** * Convert list of partitions to a PartitionSpec object. */ private static PartitionSpec getSharedSDPartSpec(Table table, StorageDescriptorKey sdKey, List<PartitionWithoutSD> partitions) { StorageDescriptor sd; if (sdKey.getSd() == null) { //sd is not requested set it empty StorageDescriptor in the PartitionSpec sd = new StorageDescriptor(); } else { sd = new StorageDescriptor(sdKey.getSd()); sd.setLocation(sdKey.baseLocation); // Use table-dir as root-dir. } PartitionSpecWithSharedSD sharedSDPartSpec = new PartitionSpecWithSharedSD(); sharedSDPartSpec.setPartitions(partitions); sharedSDPartSpec.setSd(sd); PartitionSpec ret = new PartitionSpec(); ret.setRootPath(sd.getLocation()); ret.setSharedSDPartitionSpec(sharedSDPartSpec); ret.setDbName(table.getDbName()); ret.setTableName(table.getTableName()); return ret; }
@Test public void testAddPartitionSpecWithSharedSDUpperCaseDBAndTableName() throws Exception { Table table = createTable(); PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2013"), 1); List<PartitionWithoutSD> partitions = Lists.newArrayList(partition); String location = table.getSd().getLocation() + "/sharedSDTest/"; PartitionSpec partitionSpec = new PartitionSpec(); partitionSpec.setDbName(DB_NAME.toUpperCase()); partitionSpec.setTableName(TABLE_NAME.toUpperCase()); PartitionSpecWithSharedSD partitionList = new PartitionSpecWithSharedSD(); partitionList.setPartitions(partitions); partitionList.setSd(buildSD(location)); partitionSpec.setSharedSDPartitionSpec(partitionList); PartitionSpecProxy partitionSpecProxy = PartitionSpecProxy.Factory.get(partitionSpec); client.add_partitions_pspec(partitionSpecProxy); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2013"); Assert.assertNotNull(part); Assert.assertEquals(DB_NAME, part.getDbName()); Assert.assertEquals(TABLE_NAME, part.getTableName()); Assert.assertEquals(metaStore.getWarehouseRoot() + "/" + TABLE_NAME + "/sharedSDTest/partwithoutsd1", part.getSd().getLocation()); }
public void setFieldValue(_Fields field, Object value) { switch (field) { case PARTITIONS: if (value == null) { unsetPartitions(); } else { setPartitions((List<PartitionWithoutSD>)value); } break; case SD: if (value == null) { unsetSd(); } else { setSd((StorageDescriptor)value); } break; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case PARTITIONS: if (value == null) { unsetPartitions(); } else { setPartitions((List<PartitionWithoutSD>)value); } break; case SD: if (value == null) { unsetSd(); } else { setSd((StorageDescriptor)value); } break; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case PARTITIONS: if (value == null) { unsetPartitions(); } else { setPartitions((List<PartitionWithoutSD>)value); } break; case SD: if (value == null) { unsetSd(); } else { setSd((StorageDescriptor)value); } break; } }