use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class QTestUtil method executeTestCommand.
private int executeTestCommand(final String command) {
String commandName = command.trim().split("\\s+")[0];
String commandArgs = command.trim().substring(commandName.length());
if (commandArgs.endsWith(";")) {
commandArgs = StringUtils.chop(commandArgs);
}
// replace ${hiveconf:hive.metastore.warehouse.dir} with actual dir if existed.
// we only want the absolute path, so remove the header, such as hdfs://localhost:57145
String wareHouseDir = SessionState.get().getConf().getVar(ConfVars.METASTOREWAREHOUSE).replaceAll("^[a-zA-Z]+://.*?:\\d+", "");
commandArgs = commandArgs.replaceAll("\\$\\{hiveconf:hive\\.metastore\\.warehouse\\.dir\\}", wareHouseDir);
if (SessionState.get() != null) {
SessionState.get().setLastCommand(commandName + " " + commandArgs.trim());
}
enableTestOnlyCmd(SessionState.get().getConf());
try {
CommandProcessor proc = getTestCommand(commandName);
if (proc != null) {
CommandProcessorResponse response = proc.run(commandArgs.trim());
int rc = response.getResponseCode();
if (rc != 0) {
SessionState.getConsole().printError(response.toString(), response.getException() != null ? Throwables.getStackTraceAsString(response.getException()) : "");
}
return rc;
} else {
throw new RuntimeException("Could not get CommandProcessor for command: " + commandName);
}
} catch (Exception e) {
throw new RuntimeException("Could not execute test command", e);
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHCatLoaderEncryption method executeStatementOnDriver.
/**
* Execute Hive CLI statement
* @param cmd arbitrary statement to execute
*/
static void executeStatementOnDriver(String cmd, IDriver driver) throws Exception {
LOG.debug("Executing: " + cmd);
CommandProcessorResponse cpr = driver.run(cmd);
if (cpr.getResponseCode() != 0) {
throw new IOException("Failed to execute \"" + cmd + "\". Driver returned " + cpr.getResponseCode() + " Error: " + cpr.getErrorMessage());
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestMsgBusConnection method runQuery.
private void runQuery(String query) throws Exception {
CommandProcessorResponse cpr = driver.run(query);
assertFalse(cpr.getMessage(), cpr.failed());
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestStreaming method runDDL.
private static boolean runDDL(IDriver driver, String sql) throws QueryFailedException {
LOG.debug(sql);
System.out.println(sql);
// LOG.debug("Running Hive Query: "+ sql);
CommandProcessorResponse cpr = driver.run(sql);
if (cpr.getResponseCode() == 0) {
return true;
}
LOG.error("Statement: " + sql + " failed: " + cpr);
return false;
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorResponse in project hive by apache.
the class TestHiveTestEnvSetup method testMappingSameQuery.
@Test
public void testMappingSameQuery() throws ParseException, Exception {
IDriver driver = createDriver();
String query = "select sum(u*u),sum(u) from tu where u>1";
CommandProcessorResponse ret = driver.run(query);
assertEquals(0, ret.getResponseCode());
List res = new ArrayList();
driver.getFetchTask().fetch(res);
System.out.println(res);
assertEquals(1, res.size());
assertEquals("13\t5", res.get(0));
}
Aggregations