Search in sources :

Example 1 with TExecuteStatementResp

use of org.apache.hive.service.rpc.thrift.TExecuteStatementResp in project hive by apache.

the class ThriftCLIService method ExecuteStatement.

@Override
public TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req) throws TException {
    TExecuteStatementResp resp = new TExecuteStatementResp();
    try {
        SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle());
        String statement = req.getStatement();
        Map<String, String> confOverlay = req.getConfOverlay();
        Boolean runAsync = req.isRunAsync();
        long queryTimeout = req.getQueryTimeout();
        OperationHandle operationHandle = runAsync ? cliService.executeStatementAsync(sessionHandle, statement, confOverlay, queryTimeout) : cliService.executeStatement(sessionHandle, statement, confOverlay, queryTimeout);
        resp.setOperationHandle(operationHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        // Note: it's rather important that this (and other methods) catch Exception, not Throwable;
        // in combination with HiveSessionProxy.invoke code, perhaps unintentionally, it used
        // to also catch all errors; and now it allows OOMs only to propagate.
        LOG.warn("Error executing statement: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) TExecuteStatementResp(org.apache.hive.service.rpc.thrift.TExecuteStatementResp) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 2 with TExecuteStatementResp

use of org.apache.hive.service.rpc.thrift.TExecuteStatementResp 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);
    }
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TExecuteStatementReq(org.apache.hive.service.rpc.thrift.TExecuteStatementReq) OperationHandle(org.apache.hive.service.cli.OperationHandle) TExecuteStatementResp(org.apache.hive.service.rpc.thrift.TExecuteStatementResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 3 with TExecuteStatementResp

use of org.apache.hive.service.rpc.thrift.TExecuteStatementResp in project hive by apache.

the class HiveStatement method runAsyncOnServer.

private void runAsyncOnServer(String sql) throws SQLException {
    checkConnection("execute");
    closeClientOperation();
    initFlags();
    TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql);
    /**
     * Run asynchronously whenever possible
     * Currently only a SQLOperation can be run asynchronously,
     * in a background operation thread
     * Compilation can run asynchronously or synchronously and execution run asynchronously
     */
    execReq.setRunAsync(true);
    execReq.setConfOverlay(sessConf);
    execReq.setQueryTimeout(queryTimeout);
    try {
        TExecuteStatementResp execResp = client.ExecuteStatement(execReq);
        Utils.verifySuccessWithInfo(execResp.getStatus());
        stmtHandle = execResp.getOperationHandle();
        isExecuteStatementFailed = false;
    } catch (SQLException eS) {
        isExecuteStatementFailed = true;
        throw eS;
    } catch (Exception ex) {
        isExecuteStatementFailed = true;
        throw new SQLException(ex.toString(), "08S01", ex);
    }
}
Also used : SQLException(java.sql.SQLException) TExecuteStatementReq(org.apache.hive.service.rpc.thrift.TExecuteStatementReq) TExecuteStatementResp(org.apache.hive.service.rpc.thrift.TExecuteStatementResp) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLTimeoutException(java.sql.SQLTimeoutException) SQLException(java.sql.SQLException) TException(org.apache.thrift.TException)

Aggregations

TExecuteStatementResp (org.apache.hive.service.rpc.thrift.TExecuteStatementResp)3 TException (org.apache.thrift.TException)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 OperationHandle (org.apache.hive.service.cli.OperationHandle)2 TExecuteStatementReq (org.apache.hive.service.rpc.thrift.TExecuteStatementReq)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)1 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)1 SQLTimeoutException (java.sql.SQLTimeoutException)1 LoginException (javax.security.auth.login.LoginException)1 ServiceException (org.apache.hive.service.ServiceException)1 SessionHandle (org.apache.hive.service.cli.SessionHandle)1 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)1