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());
}
Aggregations