Search in sources :

Example 31 with TApplicationException

use of org.apache.thrift.TApplicationException in project hive by apache.

the class TestForeignKey method addNoSuchTable.

@Test
public void addNoSuchTable() throws TException {
    Table parentTable = testTables[0];
    List<SQLPrimaryKey> pk = new SQLPrimaryKeyBuilder().onTable(parentTable).addColumn("col1").build(metaStore.getConf());
    client.addPrimaryKey(pk);
    try {
        List<SQLForeignKey> fk = new SQLForeignKeyBuilder().setTableName("nosuch").fromPrimaryKey(pk).addColumn("col2").build(metaStore.getConf());
        client.addForeignKey(fk);
        Assert.fail();
    } catch (InvalidObjectException | TApplicationException e) {
    // NOP
    }
}
Also used : SQLPrimaryKeyBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLPrimaryKeyBuilder) SQLForeignKeyBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLForeignKeyBuilder) SQLPrimaryKey(org.apache.hadoop.hive.metastore.api.SQLPrimaryKey) Table(org.apache.hadoop.hive.metastore.api.Table) SQLForeignKey(org.apache.hadoop.hive.metastore.api.SQLForeignKey) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) TApplicationException(org.apache.thrift.TApplicationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 32 with TApplicationException

use of org.apache.thrift.TApplicationException in project hive by apache.

the class TestNotNullConstraint method doubleAddNotNullConstraint.

@Test
public void doubleAddNotNullConstraint() throws TException {
    Table table = testTables[0];
    // Make sure get on a table with no key returns empty list
    NotNullConstraintsRequest rqst = new NotNullConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
    List<SQLNotNullConstraint> fetched = client.getNotNullConstraints(rqst);
    Assert.assertTrue(fetched.isEmpty());
    // Single column unnamed primary key in default catalog and database
    List<SQLNotNullConstraint> nn = new SQLNotNullConstraintBuilder().onTable(table).addColumn("col1").build(metaStore.getConf());
    client.addNotNullConstraint(nn);
    try {
        nn = new SQLNotNullConstraintBuilder().onTable(table).addColumn("col2").build(metaStore.getConf());
        client.addNotNullConstraint(nn);
        Assert.fail();
    } catch (InvalidObjectException | TApplicationException e) {
    // NOP
    }
}
Also used : SQLNotNullConstraint(org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint) SQLNotNullConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLNotNullConstraintBuilder) Table(org.apache.hadoop.hive.metastore.api.Table) NotNullConstraintsRequest(org.apache.hadoop.hive.metastore.api.NotNullConstraintsRequest) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) TApplicationException(org.apache.thrift.TApplicationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 33 with TApplicationException

use of org.apache.thrift.TApplicationException in project hive by apache.

the class TestDefaultConstraint method doubleAddUniqueConstraint.

@Test
public void doubleAddUniqueConstraint() throws TException {
    Table table = testTables[0];
    // Make sure get on a table with no key returns empty list
    DefaultConstraintsRequest rqst = new DefaultConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
    List<SQLDefaultConstraint> fetched = client.getDefaultConstraints(rqst);
    Assert.assertTrue(fetched.isEmpty());
    // Single column unnamed primary key in default catalog and database
    List<SQLDefaultConstraint> dv = new SQLDefaultConstraintBuilder().onTable(table).addColumn("col1").setDefaultVal(0).build(metaStore.getConf());
    client.addDefaultConstraint(dv);
    try {
        dv = new SQLDefaultConstraintBuilder().onTable(table).addColumn("col2").setDefaultVal("this string intentionally left empty").build(metaStore.getConf());
        client.addDefaultConstraint(dv);
        Assert.fail();
    } catch (InvalidObjectException | TApplicationException e) {
    // NOP
    }
}
Also used : DefaultConstraintsRequest(org.apache.hadoop.hive.metastore.api.DefaultConstraintsRequest) SQLDefaultConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLDefaultConstraintBuilder) Table(org.apache.hadoop.hive.metastore.api.Table) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) SQLDefaultConstraint(org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint) TApplicationException(org.apache.thrift.TApplicationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 34 with TApplicationException

use of org.apache.thrift.TApplicationException in project hive by apache.

the class TestUniqueConstraint method doubleAddUniqueConstraint.

@Test
public void doubleAddUniqueConstraint() throws TException {
    Table table = testTables[0];
    // Make sure get on a table with no key returns empty list
    UniqueConstraintsRequest rqst = new UniqueConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
    List<SQLUniqueConstraint> fetched = client.getUniqueConstraints(rqst);
    Assert.assertTrue(fetched.isEmpty());
    // Single column unnamed primary key in default catalog and database
    List<SQLUniqueConstraint> uc = new SQLUniqueConstraintBuilder().onTable(table).addColumn("col1").build(metaStore.getConf());
    client.addUniqueConstraint(uc);
    try {
        uc = new SQLUniqueConstraintBuilder().onTable(table).addColumn("col2").build(metaStore.getConf());
        client.addUniqueConstraint(uc);
        Assert.fail();
    } catch (InvalidObjectException | TApplicationException e) {
    // NOP
    }
}
Also used : UniqueConstraintsRequest(org.apache.hadoop.hive.metastore.api.UniqueConstraintsRequest) SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) Table(org.apache.hadoop.hive.metastore.api.Table) SQLUniqueConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLUniqueConstraintBuilder) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) TApplicationException(org.apache.thrift.TApplicationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 35 with TApplicationException

use of org.apache.thrift.TApplicationException in project hive by apache.

the class TestUniqueConstraint method addNoSuchTable.

@Test
public void addNoSuchTable() throws TException {
    try {
        List<SQLUniqueConstraint> uc = new SQLUniqueConstraintBuilder().setTableName("nosuch").addColumn("col2").build(metaStore.getConf());
        client.addUniqueConstraint(uc);
        Assert.fail();
    } catch (InvalidObjectException | TApplicationException e) {
    // NOP
    }
}
Also used : SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) SQLUniqueConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLUniqueConstraintBuilder) InvalidObjectException(org.apache.hadoop.hive.metastore.api.InvalidObjectException) TApplicationException(org.apache.thrift.TApplicationException) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

TApplicationException (org.apache.thrift.TApplicationException)38 TException (org.apache.thrift.TException)16 Test (org.junit.Test)14 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)12 TMessage (org.apache.thrift.protocol.TMessage)12 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)11 Table (org.apache.hadoop.hive.metastore.api.Table)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)6 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)6 Method (java.lang.reflect.Method)5 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)5 SQLPrimaryKey (org.apache.hadoop.hive.metastore.api.SQLPrimaryKey)5 SQLPrimaryKeyBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLPrimaryKeyBuilder)5 SQLForeignKey (org.apache.hadoop.hive.metastore.api.SQLForeignKey)4 SQLForeignKeyBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLForeignKeyBuilder)4 TBase (org.apache.thrift.TBase)4 TFieldIdEnum (org.apache.thrift.TFieldIdEnum)4