use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testInsertNonPartTable.
@Test
public void testInsertNonPartTable() throws Exception {
//case 1 is non-partitioned table.
String tableName = "nonpart";
CommandProcessorResponse ret = driver.run("CREATE TABLE " + tableName + " (key string, value string)");
Assert.assertEquals(0, ret.getResponseCode());
String tableLoc = warehouseDir + "/" + tableName;
assertExistence(warehouseDir + "/" + tableName);
//case1A: insert into non-partitioned table.
setPermission(warehouseDir + "/" + tableName);
ret = driver.run("insert into table " + tableName + " select key,value from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
verifyPermission(warehouseDir + "/" + tableName);
Assert.assertTrue(listStatus(tableLoc).size() > 0);
for (String child : listStatus(tableLoc)) {
verifyPermission(child);
}
//case1B: insert overwrite non-partitioned-table
setPermission(warehouseDir + "/" + tableName, 1);
ret = driver.run("insert overwrite table " + tableName + " select key,value from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
verifyPermission(warehouseDir + "/" + tableName, 1);
Assert.assertTrue(listStatus(tableLoc).size() > 0);
for (String child : listStatus(tableLoc)) {
verifyPermission(child, 1);
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHBaseMetastoreSql method insertIntoPartitionTable.
@Test
public void insertIntoPartitionTable() throws Exception {
driver.run("create table iipt (c int) partitioned by (ds string)");
CommandProcessorResponse rsp = driver.run("insert into table iipt partition(ds) values (1, 'today'), (2, 'yesterday')," + "(3, 'tomorrow')");
Assert.assertEquals(0, rsp.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHBaseMetastoreSql method partitionedTable.
@Test
public void partitionedTable() throws Exception {
driver.run("create table parttbl (c int) partitioned by (ds string)");
CommandProcessorResponse rsp = driver.run("insert into table parttbl partition(ds) values (1, 'today'), (2, 'yesterday')" + ", (3, 'tomorrow')");
Assert.assertEquals(0, rsp.getResponseCode());
// Do it again, to check insert into existing partitions
rsp = driver.run("insert into table parttbl partition(ds) values (4, 'today'), (5, 'yesterday')" + ", (6, 'tomorrow')");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("insert into table parttbl partition(ds = 'someday') values (1)");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("insert into table parttbl partition(ds = 'someday') values (2)");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("alter table parttbl add partition (ds = 'whenever')");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("insert into table parttbl partition(ds = 'whenever') values (2)");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("alter table parttbl touch partition (ds = 'whenever')");
Assert.assertEquals(0, rsp.getResponseCode());
// TODO - Can't do this until getPartitionsByExpr implemented
/*
rsp = driver.run("alter table parttbl drop partition (ds = 'whenever')");
Assert.assertEquals(0, rsp.getResponseCode());
*/
rsp = driver.run("select * from parttbl");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("select * from parttbl where ds = 'today'");
Assert.assertEquals(0, rsp.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHBaseMetastoreSql method role.
@Test
public void role() throws Exception {
CommandProcessorResponse rsp = driver.run("set role admin");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("create role role1");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("grant role1 to user fred with admin option");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("create role role2");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("grant role1 to role role2");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("show principals role1");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("show role grant role role1");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("show role grant user " + System.getProperty("user.name"));
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("show roles");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("revoke admin option for role1 from user fred");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("revoke role1 from user fred");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("revoke role1 from role role2");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("show current roles");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("drop role role2");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("drop role role1");
Assert.assertEquals(0, rsp.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHBaseMetastoreSql method alterRenamePartitioned.
@Test
public void alterRenamePartitioned() throws Exception {
driver.run("create table alterrename (c int) partitioned by (ds string)");
driver.run("alter table alterrename add partition (ds = 'a')");
CommandProcessorResponse rsp = driver.run("describe extended alterrename partition (ds='a')");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("alter table alterrename rename to alter_renamed");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("describe extended alter_renamed partition (ds='a')");
Assert.assertEquals(0, rsp.getResponseCode());
rsp = driver.run("describe extended alterrename partition (ds='a')");
Assert.assertEquals(10001, rsp.getResponseCode());
}
Aggregations