Search in sources :

Example 1 with TGetPrimaryKeysResp

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

the class ThriftCLIService method GetPrimaryKeys.

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

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

the class ThriftCLIServiceClient method getPrimaryKeys.

@Override
public OperationHandle getPrimaryKeys(SessionHandle sessionHandle, String catalog, String schema, String table) throws HiveSQLException {
    try {
        TGetPrimaryKeysReq req = new TGetPrimaryKeysReq(sessionHandle.toTSessionHandle());
        req.setCatalogName(catalog);
        req.setSchemaName(schema);
        req.setTableName(table);
        TGetPrimaryKeysResp resp = cliService.GetPrimaryKeys(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 : TGetPrimaryKeysReq(org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq) TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetPrimaryKeysResp(org.apache.hive.service.rpc.thrift.TGetPrimaryKeysResp) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 3 with TGetPrimaryKeysResp

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

the class HiveDatabaseMetaData method getPrimaryKeys.

public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
    TGetPrimaryKeysResp getPKResp;
    TGetPrimaryKeysReq getPKReq = new TGetPrimaryKeysReq(sessHandle);
    getPKReq.setTableName(table);
    getPKReq.setSchemaName(schema);
    getPKReq.setCatalogName(catalog);
    try {
        getPKResp = client.GetPrimaryKeys(getPKReq);
    } catch (TException e) {
        throw new SQLException(e.getMessage(), "08S01", e);
    }
    Utils.verifySuccess(getPKResp.getStatus());
    return new HiveQueryResultSet.Builder(connection).setClient(client).setSessionHandle(sessHandle).setStmtHandle(getPKResp.getOperationHandle()).build();
}
Also used : TException(org.apache.thrift.TException) TGetPrimaryKeysReq(org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq) SQLException(java.sql.SQLException) TGetPrimaryKeysResp(org.apache.hive.service.rpc.thrift.TGetPrimaryKeysResp)

Aggregations

TGetPrimaryKeysResp (org.apache.hive.service.rpc.thrift.TGetPrimaryKeysResp)3 TException (org.apache.thrift.TException)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 OperationHandle (org.apache.hive.service.cli.OperationHandle)2 TGetPrimaryKeysReq (org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)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