Search in sources :

Example 16 with CommandProcessorResponse

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);
    }
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) Test(org.junit.Test)

Example 17 with CommandProcessorResponse

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());
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) Test(org.junit.Test)

Example 18 with CommandProcessorResponse

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());
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) Test(org.junit.Test)

Example 19 with CommandProcessorResponse

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());
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) Test(org.junit.Test)

Example 20 with CommandProcessorResponse

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());
}
Also used : CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) Test(org.junit.Test)

Aggregations

CommandProcessorResponse (org.apache.hadoop.hive.ql.processors.CommandProcessorResponse)145 Test (org.junit.Test)92 ShowLocksResponseElement (org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement)24 HCatBaseTest (org.apache.hive.hcatalog.mapreduce.HCatBaseTest)19 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)17 AddDynamicPartitions (org.apache.hadoop.hive.metastore.api.AddDynamicPartitions)8 Database (org.apache.hadoop.hive.metastore.api.Database)8 HiveConf (org.apache.hadoop.hive.conf.HiveConf)7 Table (org.apache.hadoop.hive.metastore.api.Table)7 Path (org.apache.hadoop.fs.Path)6 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)6 PigServer (org.apache.pig.PigServer)5 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)4 Driver (org.apache.hadoop.hive.ql.Driver)4 IDriver (org.apache.hadoop.hive.ql.IDriver)4 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)4 PerfLogger (org.apache.hadoop.hive.ql.log.PerfLogger)4 ParseException (org.apache.hadoop.hive.ql.parse.ParseException)4 HashMap (java.util.HashMap)3