use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testCreateTableIfNotExists.
@Test
public void testCreateTableIfNotExists() throws MetaException, TException, NoSuchObjectException, CommandNeedRetryException {
hcatDriver.run("drop table " + TBL_NAME);
hcatDriver.run("create table " + TBL_NAME + " (a int) stored as RCFILE");
Table tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, TBL_NAME);
List<FieldSchema> cols = tbl.getSd().getCols();
assertEquals(1, cols.size());
assertTrue(cols.get(0).equals(new FieldSchema("a", "int", null)));
assertEquals(RCFileInputFormat.class.getName(), tbl.getSd().getInputFormat());
assertEquals(RCFileOutputFormat.class.getName(), tbl.getSd().getOutputFormat());
CommandProcessorResponse resp = hcatDriver.run("create table if not exists junit_sem_analysis (a int) stored as RCFILE");
assertEquals(0, resp.getResponseCode());
assertNull(resp.getErrorMessage());
tbl = client.getTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, TBL_NAME);
cols = tbl.getSd().getCols();
assertEquals(1, cols.size());
assertTrue(cols.get(0).equals(new FieldSchema("a", "int", null)));
assertEquals(RCFileInputFormat.class.getName(), tbl.getSd().getInputFormat());
assertEquals(RCFileOutputFormat.class.getName(), tbl.getSd().getOutputFormat());
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 testAlterTblClusteredBy.
@Test
public void testAlterTblClusteredBy() throws CommandNeedRetryException {
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 clustered by (a) into 7 buckets");
assertEquals(0, response.getResponseCode());
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 testInvalidateClusteredBy.
@Test
public void testInvalidateClusteredBy() throws IOException, CommandNeedRetryException {
hcatDriver.run("drop table junit_sem_analysis");
query = "create table junit_sem_analysis (a int) partitioned by (b string) clustered by (a) into 10 buckets stored as TEXTFILE";
CommandProcessorResponse response = hcatDriver.run(query);
assertEquals(0, response.getResponseCode());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestSemanticAnalysis method testCTLPass.
@Test
public void testCTLPass() throws IOException, MetaException, TException, NoSuchObjectException, CommandNeedRetryException {
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 testAlterTblTouch.
@Test
public void testAlterTblTouch() throws CommandNeedRetryException {
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 touch");
assertEquals(0, response.getResponseCode());
hcatDriver.run("alter table junit_sem_analysis touch partition (b='12')");
assertEquals(0, response.getResponseCode());
hcatDriver.run("drop table junit_sem_analysis");
}
Aggregations