Search in sources :

Example 1 with TGetSchemasReq

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

the class ThriftCLIServiceClient method getSchemas.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getSchemas(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String)
   */
@Override
public OperationHandle getSchemas(SessionHandle sessionHandle, String catalogName, String schemaName) throws HiveSQLException {
    try {
        TGetSchemasReq req = new TGetSchemasReq(sessionHandle.toTSessionHandle());
        req.setCatalogName(catalogName);
        req.setSchemaName(schemaName);
        TGetSchemasResp resp = cliService.GetSchemas(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) TGetSchemasReq(org.apache.hive.service.rpc.thrift.TGetSchemasReq) TGetSchemasResp(org.apache.hive.service.rpc.thrift.TGetSchemasResp) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 2 with TGetSchemasReq

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

the class HiveDatabaseMetaData method getSchemas.

public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
    TGetSchemasResp schemaResp;
    TGetSchemasReq schemaReq = new TGetSchemasReq();
    schemaReq.setSessionHandle(sessHandle);
    if (catalog != null) {
        schemaReq.setCatalogName(catalog);
    }
    if (schemaPattern == null) {
        schemaPattern = "%";
    }
    schemaReq.setSchemaName(schemaPattern);
    try {
        schemaResp = client.GetSchemas(schemaReq);
    } catch (TException e) {
        throw new SQLException(e.getMessage(), "08S01", e);
    }
    Utils.verifySuccess(schemaResp.getStatus());
    return new HiveQueryResultSet.Builder(connection).setClient(client).setSessionHandle(sessHandle).setStmtHandle(schemaResp.getOperationHandle()).build();
}
Also used : TException(org.apache.thrift.TException) SQLException(java.sql.SQLException) TGetSchemasReq(org.apache.hive.service.rpc.thrift.TGetSchemasReq) TGetSchemasResp(org.apache.hive.service.rpc.thrift.TGetSchemasResp)

Aggregations

TGetSchemasReq (org.apache.hive.service.rpc.thrift.TGetSchemasReq)2 TGetSchemasResp (org.apache.hive.service.rpc.thrift.TGetSchemasResp)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 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)1