Search in sources :

Example 21 with SQLPrimaryKeyBuilder

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

the class TestPrimaryKey method inOtherCatalog.

@Test
public void inOtherCatalog() throws TException {
    PrimaryKeysRequest rqst = new PrimaryKeysRequest(testTables[2].getDbName(), testTables[2].getTableName());
    rqst.setCatName(testTables[2].getCatName());
    List<SQLPrimaryKey> fetched = client.getPrimaryKeys(rqst);
    Assert.assertTrue(fetched.isEmpty());
    String constraintName = "ocpk";
    // Table in non 'hive' catalog
    List<SQLPrimaryKey> pk = new SQLPrimaryKeyBuilder().onTable(testTables[2]).addColumn("col1").setConstraintName(constraintName).build(metaStore.getConf());
    client.addPrimaryKey(pk);
    rqst = new PrimaryKeysRequest(testTables[2].getDbName(), testTables[2].getTableName());
    rqst.setCatName(testTables[2].getCatName());
    fetched = client.getPrimaryKeys(rqst);
    Assert.assertEquals(pk, fetched);
    client.dropConstraint(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName(), constraintName);
    rqst = new PrimaryKeysRequest(testTables[2].getDbName(), testTables[2].getTableName());
    rqst.setCatName(testTables[2].getCatName());
    fetched = client.getPrimaryKeys(rqst);
    Assert.assertTrue(fetched.isEmpty());
}
Also used : SQLPrimaryKeyBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLPrimaryKeyBuilder) SQLPrimaryKey(org.apache.hadoop.hive.metastore.api.SQLPrimaryKey) PrimaryKeysRequest(org.apache.hadoop.hive.metastore.api.PrimaryKeysRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

SQLPrimaryKey (org.apache.hadoop.hive.metastore.api.SQLPrimaryKey)21 SQLPrimaryKeyBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLPrimaryKeyBuilder)21 Test (org.junit.Test)21 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)19 Table (org.apache.hadoop.hive.metastore.api.Table)18 SQLForeignKey (org.apache.hadoop.hive.metastore.api.SQLForeignKey)13 SQLForeignKeyBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLForeignKeyBuilder)13 PrimaryKeysRequest (org.apache.hadoop.hive.metastore.api.PrimaryKeysRequest)8 ForeignKeysRequest (org.apache.hadoop.hive.metastore.api.ForeignKeysRequest)7 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)5 TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)5 TApplicationException (org.apache.thrift.TApplicationException)5 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)3 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)3 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)3 SQLDefaultConstraintBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLDefaultConstraintBuilder)3 SQLUniqueConstraintBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLUniqueConstraintBuilder)3 AllTableConstraintsRequest (org.apache.hadoop.hive.metastore.api.AllTableConstraintsRequest)2 SQLAllTableConstraints (org.apache.hadoop.hive.metastore.api.SQLAllTableConstraints)2 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)2