use of org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint in project hive by apache.
the class TestUniqueConstraint method inOtherCatalog.
@Test
public void inOtherCatalog() throws TException {
String constraintName = "ocuc";
// Table in non 'hive' catalog
List<SQLUniqueConstraint> uc = new SQLUniqueConstraintBuilder().onTable(testTables[2]).addColumn("col1").setConstraintName(constraintName).build(metaStore.getConf());
client.addUniqueConstraint(uc);
UniqueConstraintsRequest rqst = new UniqueConstraintsRequest(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName());
List<SQLUniqueConstraint> fetched = client.getUniqueConstraints(rqst);
Assert.assertEquals(uc, fetched);
client.dropConstraint(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName(), constraintName);
rqst = new UniqueConstraintsRequest(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName());
fetched = client.getUniqueConstraints(rqst);
Assert.assertTrue(fetched.isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint 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
}
}
Aggregations