Search in sources :

Example 11 with PartitionBuilder

use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.

the class TestAlterPartitions method testAlterPartitionWithEnvironmentCtxIncompletePartitionVals.

@Test(expected = MetaException.class)
public void testAlterPartitionWithEnvironmentCtxIncompletePartitionVals() throws Exception {
    createTable4PartColsParts(client);
    Table t = client.getTable(DB_NAME, TABLE_NAME);
    PartitionBuilder builder = new PartitionBuilder();
    Partition part = builder.fromTable(t).addValue("2017").build();
    client.alter_partition(DB_NAME, TABLE_NAME, part, new EnvironmentContext());
}
Also used : EnvironmentContext(org.apache.hadoop.hive.metastore.api.EnvironmentContext) Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 12 with PartitionBuilder

use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.

the class TestAlterPartitions method testAlterPartitionsUnknownPartition.

@Test
public void testAlterPartitionsUnknownPartition() throws Exception {
    Partition part1 = null;
    try {
        createTable4PartColsParts(client);
        Table t = client.getTable(DB_NAME, TABLE_NAME);
        PartitionBuilder builder = new PartitionBuilder();
        Partition part = builder.fromTable(t).addValue("1111").addValue("11").addValue("11").build();
        part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short) -1).get(0);
        makeTestChangesOnPartition(part1);
        client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1));
        fail("Should have thrown InvalidOperationException");
    } catch (InvalidOperationException e) {
        part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short) -1).get(0);
        assertPartitionUnchanged(part1, part1.getValues(), PARTCOL_SCHEMA);
    }
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 13 with PartitionBuilder

use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.

the class TestAlterPartitions method testAlterPartitionWithEnvironmentCtxMissingPartitionVals.

@Test(expected = MetaException.class)
public void testAlterPartitionWithEnvironmentCtxMissingPartitionVals() throws Exception {
    createTable4PartColsParts(client);
    Table t = client.getTable(DB_NAME, TABLE_NAME);
    PartitionBuilder builder = new PartitionBuilder();
    Partition part = builder.fromTable(t).build();
    client.alter_partition(DB_NAME, TABLE_NAME, part, new EnvironmentContext());
}
Also used : EnvironmentContext(org.apache.hadoop.hive.metastore.api.EnvironmentContext) Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 14 with PartitionBuilder

use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.

the class TestAlterPartitions method testAlterPartitionsWithEnvironmentCtxUnknownPartition.

@Test(expected = InvalidOperationException.class)
public void testAlterPartitionsWithEnvironmentCtxUnknownPartition() throws Exception {
    createTable4PartColsParts(client);
    Table t = client.getTable(DB_NAME, TABLE_NAME);
    PartitionBuilder builder = new PartitionBuilder();
    Partition part = builder.fromTable(t).addValue("1111").addValue("11").addValue("11").build();
    Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short) -1).get(0);
    client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1), new EnvironmentContext());
}
Also used : EnvironmentContext(org.apache.hadoop.hive.metastore.api.EnvironmentContext) Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 15 with PartitionBuilder

use of org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder in project hive by apache.

the class TestAppendPartitions method createPartition.

private void createPartition(Table table, List<String> values) throws Exception {
    Partition partition = new PartitionBuilder().fromTable(table).setValues(values).build();
    client.add_partition(partition);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) PartitionBuilder(org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder)

Aggregations

PartitionBuilder (org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder)32 Partition (org.apache.hadoop.hive.metastore.api.Partition)28 Test (org.junit.Test)22 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)20 Table (org.apache.hadoop.hive.metastore.api.Table)19 EnvironmentContext (org.apache.hadoop.hive.metastore.api.EnvironmentContext)7 TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)7 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)6 Database (org.apache.hadoop.hive.metastore.api.Database)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)3 Path (org.apache.hadoop.fs.Path)2 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)2 ListenerEvent (org.apache.hadoop.hive.metastore.events.ListenerEvent)2 Before (org.junit.Before)2 File (java.io.File)1 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)1 InvalidPartitionException (org.apache.hadoop.hive.metastore.api.InvalidPartitionException)1 UnknownTableException (org.apache.hadoop.hive.metastore.api.UnknownTableException)1