use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestTxnCommands method testSimpleAcidInsert.
@Test
public void testSimpleAcidInsert() throws Exception {
int[][] rows1 = { { 1, 2 }, { 3, 4 } };
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(rows1));
// List<String> rs = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b");
// Assert.assertEquals("Data didn't match in autocommit=true (rs)", stringifyValues(rows1), rs);
runStatementOnDriver("START TRANSACTION");
int[][] rows2 = { { 5, 6 }, { 7, 8 } };
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(rows2));
List<String> allData = stringifyValues(rows1);
allData.addAll(stringifyValues(rows2));
List<String> rs0 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b");
Assert.assertEquals("Data didn't match inside tx (rs0)", allData, rs0);
runStatementOnDriver("COMMIT WORK");
dumpTableData(Table.ACIDTBL, 1, 0);
dumpTableData(Table.ACIDTBL, 2, 0);
runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b");
// txn started implicitly by previous statement
CommandProcessorResponse cpr = runStatementOnDriverNegative("COMMIT");
Assert.assertEquals("Error didn't match: " + cpr, ErrorMsg.OP_NOT_ALLOWED_WITHOUT_TXN.getErrorCode(), cpr.getErrorCode());
List<String> rs1 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " order by a,b");
Assert.assertEquals("Data didn't match inside tx (rs0)", allData, rs1);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestTxnCommands2 method runStatementOnDriver.
protected List<String> runStatementOnDriver(String stmt) throws Exception {
LOG.info("+runStatementOnDriver(" + stmt + ")");
CommandProcessorResponse cpr = d.run(stmt);
if (cpr.getResponseCode() != 0) {
throw new RuntimeException(stmt + " failed: " + cpr);
}
List<String> rs = new ArrayList<String>();
d.getResults(rs);
return rs;
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestTxnNoBuckets method testCtasBucketed.
/**
* Currently CTAS doesn't support bucketed tables. Correspondingly Acid only supports CTAS for
* unbucketed tables. This test is here to make sure that if CTAS is made to support unbucketed
* tables, that it raises a red flag for Acid.
*/
@Test
public void testCtasBucketed() throws Exception {
runStatementOnDriver("insert into " + Table.NONACIDNONBUCKET + "(a,b) values(1,2),(1,3)");
CommandProcessorResponse cpr = runStatementOnDriverNegative("create table myctas " + "clustered by (a) into 2 buckets stored as ORC TBLPROPERTIES ('transactional'='true') as " + "select a, b from " + Table.NONACIDORCTBL);
// this code doesn't propagate
int j = ErrorMsg.CTAS_PARCOL_COEXISTENCE.getErrorCode();
// Assert.assertEquals("Wrong msg", ErrorMsg.CTAS_PARCOL_COEXISTENCE.getErrorCode(), cpr.getErrorCode());
Assert.assertTrue(cpr.getErrorMessage().contains("CREATE-TABLE-AS-SELECT does not support"));
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TxnCommandsBaseForTests method runStatementOnDriver.
List<String> runStatementOnDriver(String stmt) throws Exception {
CommandProcessorResponse cpr = d.run(stmt);
if (cpr.getResponseCode() != 0) {
throw new RuntimeException(stmt + " failed: " + cpr);
}
List<String> rs = new ArrayList<String>();
d.getResults(rs);
return rs;
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestOperators method testFetchOperatorContext.
@Test
public void testFetchOperatorContext() throws Exception {
HiveConf conf = new HiveConf();
conf.set("hive.support.concurrency", "false");
conf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
SessionState.start(conf);
String cmd = "create table fetchOp (id int, name string) " + "partitioned by (state string) " + "row format delimited fields terminated by '|' " + "stored as " + "inputformat 'org.apache.hadoop.hive.ql.exec.TestOperators$CustomInFmt' " + "outputformat 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' " + "tblproperties ('myprop1'='val1', 'myprop2' = 'val2')";
Driver driver = new Driver(conf);
CommandProcessorResponse response = driver.run(cmd);
assertEquals(0, response.getResponseCode());
List<Object> result = new ArrayList<Object>();
cmd = "load data local inpath '../data/files/employee.dat' " + "overwrite into table fetchOp partition (state='CA')";
response = driver.run(cmd);
assertEquals(0, response.getResponseCode());
cmd = "load data local inpath '../data/files/employee2.dat' " + "overwrite into table fetchOp partition (state='OR')";
response = driver.run(cmd);
assertEquals(0, response.getResponseCode());
cmd = "select * from fetchOp";
driver.setMaxRows(500);
response = driver.run(cmd);
assertEquals(0, response.getResponseCode());
driver.getResults(result);
assertEquals(20, result.size());
driver.close();
}
Aggregations