Search in sources :

Example 1 with TGetCrossReferenceReq

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

the class HiveDatabaseMetaData method getCrossReference.

public ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException {
    TGetCrossReferenceResp getFKResp;
    TGetCrossReferenceReq getFKReq = new TGetCrossReferenceReq(sessHandle);
    getFKReq.setParentTableName(primaryTable);
    getFKReq.setParentSchemaName(primarySchema);
    getFKReq.setParentCatalogName(primaryCatalog);
    getFKReq.setForeignTableName(foreignTable);
    getFKReq.setForeignSchemaName(foreignSchema);
    getFKReq.setForeignCatalogName(foreignCatalog);
    try {
        getFKResp = client.GetCrossReference(getFKReq);
    } catch (TException e) {
        throw new SQLException(e.getMessage(), "08S01", e);
    }
    Utils.verifySuccess(getFKResp.getStatus());
    return new HiveQueryResultSet.Builder(connection).setClient(client).setStmtHandle(getFKResp.getOperationHandle()).build();
}
Also used : TException(org.apache.thrift.TException) SQLException(java.sql.SQLException) TGetCrossReferenceReq(org.apache.hive.service.rpc.thrift.TGetCrossReferenceReq) TGetCrossReferenceResp(org.apache.hive.service.rpc.thrift.TGetCrossReferenceResp)

Example 2 with TGetCrossReferenceReq

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

the class ThriftCLIServiceClient method getCrossReference.

@Override
public OperationHandle getCrossReference(SessionHandle sessionHandle, String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws HiveSQLException {
    try {
        TGetCrossReferenceReq req = new TGetCrossReferenceReq(sessionHandle.toTSessionHandle());
        req.setParentCatalogName(primaryCatalog);
        req.setParentSchemaName(primarySchema);
        req.setParentTableName(primaryTable);
        req.setForeignCatalogName(foreignCatalog);
        req.setForeignSchemaName(foreignSchema);
        req.setForeignTableName(foreignTable);
        TGetCrossReferenceResp resp = cliService.GetCrossReference(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) TGetCrossReferenceReq(org.apache.hive.service.rpc.thrift.TGetCrossReferenceReq) TGetCrossReferenceResp(org.apache.hive.service.rpc.thrift.TGetCrossReferenceResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) 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)

Aggregations

TGetCrossReferenceReq (org.apache.hive.service.rpc.thrift.TGetCrossReferenceReq)2 TGetCrossReferenceResp (org.apache.hive.service.rpc.thrift.TGetCrossReferenceResp)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