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
}
}
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
}
}
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
}
}
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
}
}
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
}
}
Aggregations