use of org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest in project hive by apache.
the class TestCheckConstraint method getNoSuchDb.
@Test
public void getNoSuchDb() throws TException {
CheckConstraintsRequest rqst = new CheckConstraintsRequest(DEFAULT_CATALOG_NAME, "nosuch", testTables[0].getTableName());
List<SQLCheckConstraint> cc = client.getCheckConstraints(rqst);
Assert.assertTrue(cc.isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest in project hive by apache.
the class TestCheckConstraint method getNoSuchTable.
@Test
public void getNoSuchTable() throws TException {
CheckConstraintsRequest rqst = new CheckConstraintsRequest(DEFAULT_CATALOG_NAME, DEFAULT_DATABASE_NAME, "nosuch");
List<SQLCheckConstraint> cc = client.getCheckConstraints(rqst);
Assert.assertTrue(cc.isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest in project hive by apache.
the class TestCheckConstraint method createTableWithConstraintsPk.
@Test
public void createTableWithConstraintsPk() throws TException {
String constraintName = "ctwccc";
Table table = new TableBuilder().setTableName("table_with_constraints").addCol("col1", "int").addCol("col2", "varchar(32)").build(metaStore.getConf());
List<SQLCheckConstraint> cc = new SQLCheckConstraintBuilder().onTable(table).addColumn("col1").setConstraintName(constraintName).setCheckExpression("> 0").build(metaStore.getConf());
client.createTableWithConstraints(table, null, null, null, null, null, cc);
CheckConstraintsRequest rqst = new CheckConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
List<SQLCheckConstraint> fetched = client.getCheckConstraints(rqst);
Assert.assertEquals(cc, fetched);
client.dropConstraint(table.getCatName(), table.getDbName(), table.getTableName(), constraintName);
rqst = new CheckConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
fetched = client.getCheckConstraints(rqst);
Assert.assertTrue(fetched.isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest in project hive by apache.
the class TestCheckConstraint method createTableWithConstraintsPkInOtherCatalog.
@Test
public void createTableWithConstraintsPkInOtherCatalog() throws TException {
Table table = new TableBuilder().setTableName("table_in_other_catalog_with_constraints").inDb(inOtherCatalog).addCol("col1", "int").addCol("col2", "varchar(32)").build(metaStore.getConf());
List<SQLCheckConstraint> cc = new SQLCheckConstraintBuilder().onTable(table).addColumn("col1").setCheckExpression("> 0").build(metaStore.getConf());
client.createTableWithConstraints(table, null, null, null, null, null, cc);
CheckConstraintsRequest rqst = new CheckConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
List<SQLCheckConstraint> fetched = client.getCheckConstraints(rqst);
cc.get(0).setDc_name(fetched.get(0).getDc_name());
Assert.assertEquals(cc, fetched);
client.dropConstraint(table.getCatName(), table.getDbName(), table.getTableName(), cc.get(0).getDc_name());
rqst = new CheckConstraintsRequest(table.getCatName(), table.getDbName(), table.getTableName());
fetched = client.getCheckConstraints(rqst);
Assert.assertTrue(fetched.isEmpty());
}
use of org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest in project hive by apache.
the class TestCheckConstraint method inOtherCatalog.
@Test
public void inOtherCatalog() throws TException {
String constraintName = "occc";
// Table in non 'hive' catalog
List<SQLCheckConstraint> cc = new SQLCheckConstraintBuilder().onTable(testTables[2]).addColumn("col1").setConstraintName(constraintName).setCheckExpression("like s%").build(metaStore.getConf());
client.addCheckConstraint(cc);
CheckConstraintsRequest rqst = new CheckConstraintsRequest(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName());
List<SQLCheckConstraint> fetched = client.getCheckConstraints(rqst);
Assert.assertEquals(cc, fetched);
client.dropConstraint(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName(), constraintName);
rqst = new CheckConstraintsRequest(testTables[2].getCatName(), testTables[2].getDbName(), testTables[2].getTableName());
fetched = client.getCheckConstraints(rqst);
Assert.assertTrue(fetched.isEmpty());
}
Aggregations