use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testCtas.
@Test
public void testCtas() throws Exception {
String testDb = "ctasdb";
String tableName = "createtable";
CommandProcessorResponse ret = driver.run("CREATE DATABASE " + testDb);
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + testDb + ".db");
setPermission(warehouseDir + "/" + testDb + ".db");
verifyPermission(warehouseDir + "/" + testDb + ".db");
ret = driver.run("USE " + testDb);
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("create table " + tableName + " as select key,value from default.mysrc");
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + testDb + ".db/" + tableName);
verifyPermission(warehouseDir + "/" + testDb + ".db/" + tableName);
Assert.assertTrue(listStatus(warehouseDir + "/" + testDb + ".db/" + tableName).size() > 0);
for (String child : listStatus(warehouseDir + "/" + testDb + ".db/" + tableName)) {
verifyPermission(child);
}
ret = driver.run("USE default");
Assert.assertEquals(0, ret.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testInsertSingleDynamicPartition.
@Test
public void testInsertSingleDynamicPartition() throws Exception {
String tableName = "singledynamicpart";
CommandProcessorResponse ret = driver.run("CREATE TABLE " + tableName + " (key string, value string) partitioned by (part1 string)");
Assert.assertEquals(0, ret.getResponseCode());
String tableLoc = warehouseDir + "/" + tableName;
assertExistence(tableLoc);
//Insert into test, with permission set 0.
setPermission(tableLoc, 0);
ret = driver.run("insert into table " + tableName + " partition (part1) select key,value,part1 from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
verifySinglePartition(tableLoc, 0);
//Insert overwrite test, with permission set 1. We need reset existing partitions to 1 since the permissions
//should be inherited from existing partition
setSinglePartition(tableLoc, 1);
ret = driver.run("insert overwrite table " + tableName + " partition (part1) select key,value,part1 from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
verifySinglePartition(tableLoc, 1);
//delete and re-insert using insert overwrite. There's different code paths insert vs insert overwrite for new tables.
ret = driver.run("DROP TABLE " + tableName);
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("CREATE TABLE " + tableName + " (key string, value string) partitioned by (part1 string)");
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + tableName);
setPermission(warehouseDir + "/" + tableName);
ret = driver.run("insert overwrite table " + tableName + " partition (part1) select key,value,part1 from mysrc");
Assert.assertEquals(0, ret.getResponseCode());
verifySinglePartition(tableLoc, 0);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method setupDataTable.
private static void setupDataTable() throws Exception {
CommandProcessorResponse ret = driver.run("DROP TABLE IF EXISTS mysrc");
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("CREATE TABLE mysrc (key STRING, value STRING) PARTITIONED BY (part1 string, part2 string) STORED AS TEXTFILE");
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("LOAD DATA LOCAL INPATH '" + dataFilePath + "' INTO TABLE mysrc PARTITION (part1='1',part2='1')");
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("LOAD DATA LOCAL INPATH '" + dataFilePath + "' INTO TABLE mysrc PARTITION (part1='2',part2='2')");
Assert.assertEquals(0, ret.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class FolderPermissionBase method testCreateTable.
@Test
public void testCreateTable() throws Exception {
String testDb = "mydb2";
String tableName = "createtable";
CommandProcessorResponse ret = driver.run("CREATE DATABASE " + testDb);
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + testDb + ".db");
setPermission(warehouseDir + "/" + testDb + ".db");
verifyPermission(warehouseDir + "/" + testDb + ".db");
ret = driver.run("USE " + testDb);
Assert.assertEquals(0, ret.getResponseCode());
ret = driver.run("CREATE TABLE " + tableName + " (key string, value string)");
Assert.assertEquals(0, ret.getResponseCode());
verifyPermission(warehouseDir + "/" + testDb + ".db/" + tableName);
ret = driver.run("insert into table " + tableName + " select key,value from default.mysrc");
Assert.assertEquals(0, ret.getResponseCode());
assertExistence(warehouseDir + "/" + testDb + ".db/" + tableName);
verifyPermission(warehouseDir + "/" + testDb + ".db/" + tableName);
Assert.assertTrue(listStatus(warehouseDir + "/" + testDb + ".db/" + tableName).size() > 0);
for (String child : listStatus(warehouseDir + "/" + testDb + ".db/" + tableName)) {
verifyPermission(child);
}
ret = driver.run("USE default");
Assert.assertEquals(0, ret.getResponseCode());
}
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);
}
}
Aggregations