Search in sources :

Example 6 with CheckConstraintsRequest

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());
}
Also used : SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) CheckConstraintsRequest(org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 7 with CheckConstraintsRequest

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());
}
Also used : SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) CheckConstraintsRequest(org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 8 with CheckConstraintsRequest

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());
}
Also used : SQLCheckConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLCheckConstraintBuilder) Table(org.apache.hadoop.hive.metastore.api.Table) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder) CheckConstraintsRequest(org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 9 with CheckConstraintsRequest

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());
}
Also used : SQLCheckConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLCheckConstraintBuilder) Table(org.apache.hadoop.hive.metastore.api.Table) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder) CheckConstraintsRequest(org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Example 10 with CheckConstraintsRequest

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());
}
Also used : SQLCheckConstraintBuilder(org.apache.hadoop.hive.metastore.client.builder.SQLCheckConstraintBuilder) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) CheckConstraintsRequest(org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest) Test(org.junit.Test) MetastoreCheckinTest(org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)

Aggregations

CheckConstraintsRequest (org.apache.hadoop.hive.metastore.api.CheckConstraintsRequest)10 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)10 Test (org.junit.Test)10 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)8 SQLCheckConstraintBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLCheckConstraintBuilder)6 Table (org.apache.hadoop.hive.metastore.api.Table)5 TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)3 DefaultConstraintsRequest (org.apache.hadoop.hive.metastore.api.DefaultConstraintsRequest)2 ForeignKeysRequest (org.apache.hadoop.hive.metastore.api.ForeignKeysRequest)2 NotNullConstraintsRequest (org.apache.hadoop.hive.metastore.api.NotNullConstraintsRequest)2 PrimaryKeysRequest (org.apache.hadoop.hive.metastore.api.PrimaryKeysRequest)2 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)2 SQLForeignKey (org.apache.hadoop.hive.metastore.api.SQLForeignKey)2 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)2 SQLPrimaryKey (org.apache.hadoop.hive.metastore.api.SQLPrimaryKey)2 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)2 UniqueConstraintsRequest (org.apache.hadoop.hive.metastore.api.UniqueConstraintsRequest)2 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)1 SQLDefaultConstraintBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLDefaultConstraintBuilder)1 SQLForeignKeyBuilder (org.apache.hadoop.hive.metastore.client.builder.SQLForeignKeyBuilder)1