use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testCTAS.
@Test
public void testCTAS() throws Exception {
hcatDriver.run("drop table junit_sem_analysis");
query = "create table junit_sem_analysis (a int) as select * from tbl2";
CommandProcessorResponse response = hcatDriver.run(query);
assertEquals(40000, response.getResponseCode());
assertTrue(response.getErrorMessage().contains("FAILED: SemanticException Operation not supported. Create table as Select is not a valid operation."));
hcatDriver.run("drop table junit_sem_analysis");
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testAddReplaceCols.
@Test
public void testAddReplaceCols() throws Exception {
hcatDriver.run("drop table junit_sem_analysis");
hcatDriver.run("create table junit_sem_analysis (a int, c string) partitioned by (b string) stored as RCFILE");
CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis replace columns (a1 tinyint)");
assertEquals(0, response.getResponseCode());
response = hcatDriver.run("alter table junit_sem_analysis add columns (d tinyint)");
assertEquals(0, response.getResponseCode());
assertNull(response.getErrorMessage());
response = hcatDriver.run("describe extended junit_sem_analysis");
assertEquals(0, response.getResponseCode());
Table tbl = client.getTable(Warehouse.DEFAULT_DATABASE_NAME, TBL_NAME);
List<FieldSchema> cols = tbl.getSd().getCols();
assertEquals(2, cols.size());
assertTrue(cols.get(0).equals(new FieldSchema("a1", "tinyint", null)));
assertTrue(cols.get(1).equals(new FieldSchema("d", "tinyint", null)));
hcatDriver.run("drop table junit_sem_analysis");
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testCTLPass.
@Test
public void testCTLPass() throws Exception {
try {
hcatDriver.run("drop table junit_sem_analysis");
} catch (Exception e) {
LOG.error("Error in drop table.", e);
}
query = "create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE";
hcatDriver.run(query);
String likeTbl = "like_table";
hcatDriver.run("drop table " + likeTbl);
query = "create table like_table like junit_sem_analysis";
CommandProcessorResponse resp = hcatDriver.run(query);
assertEquals(0, resp.getResponseCode());
// Table tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, likeTbl);
// assertEquals(likeTbl,tbl.getTableName());
// List<FieldSchema> cols = tbl.getSd().getCols();
// assertEquals(1, cols.size());
// assertEquals(new FieldSchema("a", "int", null), cols.get(0));
// assertEquals("org.apache.hadoop.hive.ql.io.RCFileInputFormat",tbl.getSd().getInputFormat());
// assertEquals("org.apache.hadoop.hive.ql.io.RCFileOutputFormat",tbl.getSd().getOutputFormat());
// Map<String, String> tblParams = tbl.getParameters();
// assertEquals("org.apache.hadoop.hive.hcat.rcfile.RCFileInputStorageDriver", tblParams.get("hcat.isd"));
// assertEquals("org.apache.hadoop.hive.hcat.rcfile.RCFileOutputStorageDriver", tblParams.get("hcat.osd"));
//
// hcatDriver.run("drop table junit_sem_analysis");
// hcatDriver.run("drop table "+likeTbl);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testAddPartFail.
@Test
public void testAddPartFail() throws Exception {
driver.run("drop table junit_sem_analysis");
driver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE");
CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis add partition (b='2') location 'README.txt'");
assertEquals(0, response.getResponseCode());
driver.run("drop table junit_sem_analysis");
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testAddPartPass.
@Test
public void testAddPartPass() throws Exception {
hcatDriver.run("drop table junit_sem_analysis");
hcatDriver.run("create table junit_sem_analysis (a int) partitioned by (b string) stored as RCFILE");
CommandProcessorResponse response = hcatDriver.run("alter table junit_sem_analysis add partition (b='2') location '" + TEST_DATA_DIR + "'");
assertEquals(0, response.getResponseCode());
assertNull(response.getErrorMessage());
hcatDriver.run("drop table junit_sem_analysis");
}
Aggregations