Search in sources :

Example 11 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class ThriftCLIService method FetchResults.

@Override
public TFetchResultsResp FetchResults(TFetchResultsReq req) throws TException {
    TFetchResultsResp resp = new TFetchResultsResp();
    try {
        // Set fetch size
        int maxFetchSize = hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_MAX_FETCH_SIZE);
        if (req.getMaxRows() > maxFetchSize) {
            req.setMaxRows(maxFetchSize);
        }
        RowSet rowSet = cliService.fetchResults(new OperationHandle(req.getOperationHandle()), FetchOrientation.getFetchOrientation(req.getOrientation()), req.getMaxRows(), FetchType.getFetchType(req.getFetchType()));
        resp.setResults(rowSet.toTRowSet());
        resp.setHasMoreRows(false);
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error fetching results: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : TFetchResultsResp(org.apache.hive.service.rpc.thrift.TFetchResultsResp) RowSet(org.apache.hive.service.cli.RowSet) OperationHandle(org.apache.hive.service.cli.OperationHandle) 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 12 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class ThriftCLIService method GetColumns.

@Override
public TGetColumnsResp GetColumns(TGetColumnsReq req) throws TException {
    TGetColumnsResp resp = new TGetColumnsResp();
    try {
        OperationHandle opHandle = cliService.getColumns(new SessionHandle(req.getSessionHandle()), req.getCatalogName(), req.getSchemaName(), req.getTableName(), req.getColumnName());
        resp.setOperationHandle(opHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error getting columns: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) TGetColumnsResp(org.apache.hive.service.rpc.thrift.TGetColumnsResp) 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 13 with OperationHandle

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);
    }
}
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 14 with OperationHandle

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

Example 15 with OperationHandle

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

Aggregations

OperationHandle (org.apache.hive.service.cli.OperationHandle)77 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)54 SessionHandle (org.apache.hive.service.cli.SessionHandle)38 TException (org.apache.thrift.TException)27 Test (org.junit.Test)22 IOException (java.io.IOException)18 RowSet (org.apache.hive.service.cli.RowSet)16 UnknownHostException (java.net.UnknownHostException)15 LoginException (javax.security.auth.login.LoginException)15 ServiceException (org.apache.hive.service.ServiceException)15 ExploreException (co.cask.cdap.explore.service.ExploreException)12 OperationManager (org.apache.hive.service.cli.operation.OperationManager)12 QueryHandle (co.cask.cdap.proto.QueryHandle)11 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)11 OperationStatus (org.apache.hive.service.cli.OperationStatus)5 HashMap (java.util.HashMap)4 CLIServiceClient (org.apache.hive.service.cli.CLIServiceClient)4 OperationState (org.apache.hive.service.cli.OperationState)4 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)2 HandleNotFoundException (co.cask.cdap.explore.service.HandleNotFoundException)2