use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class ThriftCLIServiceClient method executeStatementInternal.
private OperationHandle executeStatementInternal(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, boolean isAsync, long queryTimeout) throws HiveSQLException {
try {
TExecuteStatementReq req = new TExecuteStatementReq(sessionHandle.toTSessionHandle(), statement);
req.setConfOverlay(confOverlay);
req.setRunAsync(isAsync);
req.setQueryTimeout(queryTimeout);
TExecuteStatementResp resp = cliService.ExecuteStatement(req);
checkStatus(resp.getStatus());
TProtocolVersion protocol = sessionHandle.getProtocolVersion();
return new OperationHandle(resp.getOperationHandle(), protocol);
} catch (HiveSQLException e) {
throw e;
} catch (Exception e) {
throw new HiveSQLException(e);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class ThriftCLIServiceClient method getCatalogs.
/* (non-Javadoc)
* @see org.apache.hive.service.cli.ICLIService#getCatalogs(org.apache.hive.service.cli.SessionHandle)
*/
@Override
public OperationHandle getCatalogs(SessionHandle sessionHandle) throws HiveSQLException {
try {
TGetCatalogsReq req = new TGetCatalogsReq(sessionHandle.toTSessionHandle());
TGetCatalogsResp resp = cliService.GetCatalogs(req);
checkStatus(resp.getStatus());
TProtocolVersion protocol = sessionHandle.getProtocolVersion();
return new OperationHandle(resp.getOperationHandle(), protocol);
} catch (HiveSQLException e) {
throw e;
} catch (Exception e) {
throw new HiveSQLException(e);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class ThriftCLIServiceClient method getFunctions.
/* (non-Javadoc)
* @see org.apache.hive.service.cli.ICLIService#getFunctions(org.apache.hive.service.cli.SessionHandle)
*/
@Override
public OperationHandle getFunctions(SessionHandle sessionHandle, String catalogName, String schemaName, String functionName) throws HiveSQLException {
try {
TGetFunctionsReq req = new TGetFunctionsReq(sessionHandle.toTSessionHandle(), functionName);
req.setCatalogName(catalogName);
req.setSchemaName(schemaName);
TGetFunctionsResp resp = cliService.GetFunctions(req);
checkStatus(resp.getStatus());
TProtocolVersion protocol = sessionHandle.getProtocolVersion();
return new OperationHandle(resp.getOperationHandle(), protocol);
} catch (HiveSQLException e) {
throw e;
} catch (Exception e) {
throw new HiveSQLException(e);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class KillQueryImpl method killQuery.
@Override
public void killQuery(String queryId, String errMsg) throws HiveException {
try {
Operation operation = operationManager.getOperationByQueryId(queryId);
if (operation == null) {
LOG.info("Query not found: " + queryId);
} else {
OperationHandle handle = operation.getHandle();
operationManager.cancelOperation(handle, errMsg);
}
} catch (HiveSQLException e) {
throw new HiveException(e);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class ThriftCLIServiceTest method testExecuteStatement.
/**
* Test synchronous query execution
* @throws Exception
*/
@Test
public void testExecuteStatement() throws Exception {
Map<String, String> opConf = new HashMap<String, String>();
// Open a new client session
SessionHandle sessHandle = client.openSession(USERNAME, PASSWORD, opConf);
// Session handle should not be null
assertNotNull("Session handle should not be null", sessHandle);
// Change lock manager to embedded mode
String queryString = "SET hive.lock.manager=" + "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager";
client.executeStatement(sessHandle, queryString, opConf);
// Drop the table if it exists
queryString = "DROP TABLE IF EXISTS TEST_EXEC_THRIFT";
client.executeStatement(sessHandle, queryString, opConf);
// Create a test table
queryString = "CREATE TABLE TEST_EXEC_THRIFT(ID STRING)";
client.executeStatement(sessHandle, queryString, opConf);
// Execute another query
queryString = "SELECT ID+1 FROM TEST_EXEC_THRIFT";
OperationHandle opHandle = client.executeStatement(sessHandle, queryString, opConf);
assertNotNull(opHandle);
OperationStatus opStatus = client.getOperationStatus(opHandle, false);
assertNotNull(opStatus);
OperationState state = opStatus.getState();
// Expect query to be completed now
assertEquals("Query should be finished", OperationState.FINISHED, state);
// Cleanup
queryString = "DROP TABLE TEST_EXEC_THRIFT";
client.executeStatement(sessHandle, queryString, opConf);
client.closeSession(sessHandle);
}
Aggregations