Search in sources :

Example 31 with PartitionSpecProxy

use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecPartDuplicateInSpecs.

@Test(expected = MetaException.class)
public void testAddPartitionSpecPartDuplicateInSpecs() throws Exception {
    createTable(DB_NAME, TABLE_NAME, getYearPartCol(), metaStore.getWarehouseRoot() + "/" + TABLE_NAME);
    Partition partition = buildPartition(Lists.newArrayList("2002"), getYearPartCol(), 1);
    PartitionWithoutSD partitionWithoutSD = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(Lists.newArrayList(partition), Lists.newArrayList(partitionWithoutSD));
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 32 with PartitionSpecProxy

use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecNullValues.

@Test(expected = MetaException.class)
public void testAddPartitionSpecNullValues() throws Exception {
    createTable();
    Partition partition = buildPartition(DB_NAME, TABLE_NAME, null);
    partition.setValues(null);
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition));
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 33 with PartitionSpecProxy

use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecWithSharedSDNullSd.

@Test(expected = MetaException.class)
public void testAddPartitionSpecWithSharedSDNullSd() throws Exception {
    createTable();
    PartitionWithoutSD partition = buildPartitionWithoutSD(Lists.newArrayList("2002"), 0);
    StorageDescriptor sd = null;
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpecWithSharedSD(Lists.newArrayList(partition), sd);
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : PartitionWithoutSD(org.apache.hadoop.hive.metastore.api.PartitionWithoutSD) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 34 with PartitionSpecProxy

use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecNoValue.

@Test(expected = MetaException.class)
public void testAddPartitionSpecNoValue() throws Exception {
    createTable();
    Partition partition = new PartitionBuilder().setDbName(DB_NAME).setTableName(TABLE_NAME).addCol(YEAR_COL_NAME, DEFAULT_COL_TYPE).setLocation(metaStore.getWarehouseRoot() + "/addpartspectest").build(metaStore.getConf());
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, Lists.newArrayList(partition));
    client.add_partitions_pspec(partitionSpecProxy);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 35 with PartitionSpecProxy

use of org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy in project hive by apache.

the class TestAddPartitionsFromPartSpec method testAddPartitionSpecMoreThanThreadCountsOneFails.

@Test
public void testAddPartitionSpecMoreThanThreadCountsOneFails() throws Exception {
    createTable();
    String tableLocation = metaStore.getWarehouseRoot() + "/" + TABLE_NAME;
    List<Partition> partitions = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        String value = String.valueOf(2000 + i);
        String location = tableLocation + "/year=" + value;
        if (i == 30) {
            location = "invalidhost:80000/wrongfolder";
        }
        Partition partition = buildPartition(DB_NAME, TABLE_NAME, value, location);
        partitions.add(partition);
    }
    PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions);
    try {
        client.add_partitions_pspec(partitionSpecProxy);
        Assert.fail("MetaException should have happened.");
    } catch (MetaException e) {
    // Expected exception
    }
    List<Partition> parts = client.listPartitions(DB_NAME, TABLE_NAME, MAX);
    Assert.assertNotNull(parts);
    Assert.assertTrue(parts.isEmpty());
    for (Partition partition : partitions) {
        if (!"invalidhost:80000/wrongfolder".equals(partition.getSd().getLocation())) {
            Assert.assertFalse(metaStore.isPathExists(new Path(partition.getSd().getLocation())));
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Partition(org.apache.hadoop.hive.metastore.api.Partition) ArrayList(java.util.ArrayList) PartitionSpecProxy(org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

PartitionSpecProxy (org.apache.hadoop.hive.metastore.partition.spec.PartitionSpecProxy)69 Test (org.junit.Test)60 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)59 Partition (org.apache.hadoop.hive.metastore.api.Partition)53 Table (org.apache.hadoop.hive.metastore.api.Table)24 PartitionWithoutSD (org.apache.hadoop.hive.metastore.api.PartitionWithoutSD)15 ArrayList (java.util.ArrayList)13 Path (org.apache.hadoop.fs.Path)11 List (java.util.List)7 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)7 HashMap (java.util.HashMap)4 PartitionSpec (org.apache.hadoop.hive.metastore.api.PartitionSpec)4 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)3 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)3 PartitionBuilder (org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder)3 CompositePartitionSpecProxy (org.apache.hadoop.hive.metastore.partition.spec.CompositePartitionSpecProxy)3 PartitionSpecWithSharedSD (org.apache.hadoop.hive.metastore.api.PartitionSpecWithSharedSD)2 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)2 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)2 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)2