Search in sources :

Example 1 with TGetPrimaryKeysReq

use of org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq 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) TOperationHandle(org.apache.hive.service.rpc.thrift.TOperationHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 2 with TGetPrimaryKeysReq

use of org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq 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).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

TGetPrimaryKeysReq (org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq)2 TGetPrimaryKeysResp (org.apache.hive.service.rpc.thrift.TGetPrimaryKeysResp)2 TException (org.apache.thrift.TException)2 SQLException (java.sql.SQLException)1 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 OperationHandle (org.apache.hive.service.cli.OperationHandle)1 TOperationHandle (org.apache.hive.service.rpc.thrift.TOperationHandle)1 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)1