use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.
the class TestMetaStoreServerUtils method testCompareWithSdSamePrefixDifferentCols.
/**
* Two StorageDescriptorKey objects with the same base location
* should be equal iff their columns are equal
*/
@Test
public void testCompareWithSdSamePrefixDifferentCols() throws MetaException {
Partition p1 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l1").addCol("a", "int").addValue("val1").build(null);
Partition p2 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l2").addCol("b", "int").addValue("val1").build(null);
Partition p3 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l2").addCol("a", "int").addValue("val1").build(null);
assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), IsNot.not(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd())));
assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p3.getSd())));
}
use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.
the class TestMetaStoreServerUtils method testCompareWithSdSamePrefixDifferentLocation.
/**
* Two StorageDescriptorKey objects with the same base location but different
* SD location should be equal
*/
@Test
public void testCompareWithSdSamePrefixDifferentLocation() throws MetaException {
Partition p1 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l1").addCol("a", "int").addValue("val1").build(null);
Partition p2 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l2").addCol("a", "int").addValue("val1").build(null);
assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd())));
}
use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.
the class TestMetaStoreServerUtils method testCompareWithSdSamePrefixDifferentInputFormat.
/**
* Two StorageDescriptorKey objects with the same base location
* should be equal iff their input formats are equal
*/
@Test
public void testCompareWithSdSamePrefixDifferentInputFormat() throws MetaException {
Partition p1 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l1").addCol("a", "int").addValue("val1").setInputFormat("foo").build(null);
Partition p2 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l2").addCol("a", "int").setInputFormat("bar").addValue("val1").build(null);
Partition p3 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("l1").addCol("a", "int").addValue("val1").setInputFormat("foo").build(null);
assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), IsNot.not(new MetaStoreServerUtils.StorageDescriptorKey("a", p2.getSd())));
assertThat(new MetaStoreServerUtils.StorageDescriptorKey("a", p1.getSd()), is(new MetaStoreServerUtils.StorageDescriptorKey("a", p3.getSd())));
}
use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.
the class TestMetaStoreServerUtils method testGetPartitionspecsGroupedBySDOnePartitionInTable.
/**
* Test getPartitionspecsGroupedByStorageDescriptor() for partitions with a single
* partition which is located under table location.
*/
@Test
public void testGetPartitionspecsGroupedBySDOnePartitionInTable() throws MetaException {
// Create database and table
Table tbl = new TableBuilder().setDbName(DB_NAME).setTableName(TABLE_NAME).addCol("id", "int").setLocation("/foo").build(null);
Partition p1 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).setLocation("/foo/bar").addCol("a", "int").addValue("val1").setInputFormat("foo").build(null);
List<PartitionSpec> result = MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(tbl, Collections.singleton(p1));
assertThat(result.size(), is(1));
PartitionSpec ps = result.get(0);
assertThat(ps.getRootPath(), is(tbl.getSd().getLocation()));
List<PartitionWithoutSD> partitions = ps.getSharedSDPartitionSpec().getPartitions();
assertThat(partitions.size(), is(1));
PartitionWithoutSD partition = partitions.get(0);
assertThat(partition.getRelativePath(), is("/bar"));
assertThat(partition.getValues(), is(Collections.singletonList("val1")));
}
use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.
the class TestMetaStoreServerUtils method testGetPartitionspecsGroupedBySDNullSD.
/**
* Test getPartitionspecsGroupedByStorageDescriptor() for partitions with null SDs.
*/
@Test
public void testGetPartitionspecsGroupedBySDNullSD() throws MetaException {
// Create database and table
Table tbl = new TableBuilder().setDbName(DB_NAME).setTableName(TABLE_NAME).addCol("id", "int").setLocation("/foo").build(null);
Partition p1 = new PartitionBuilder().setDbName("DB_NAME").setTableName(TABLE_NAME).addCol("a", "int").addValue("val1").setInputFormat("foo").build(null);
// Set SD to null
p1.unsetSd();
assertThat(p1.getSd(), is((StorageDescriptor) null));
List<PartitionSpec> result = MetaStoreServerUtils.getPartitionspecsGroupedByStorageDescriptor(tbl, Collections.singleton(p1));
assertThat(result.size(), is(1));
PartitionSpec ps = result.get(0);
assertThat(ps.getRootPath(), is((String) null));
List<PartitionWithoutSD> partitions = ps.getSharedSDPartitionSpec().getPartitions();
assertThat(partitions.size(), is(1));
PartitionWithoutSD partition = partitions.get(0);
assertThat(partition.getRelativePath(), is((String) null));
assertThat(partition.getValues(), is(Collections.singletonList("val1")));
}
Aggregations