Search in sources :

Example 1 with TGetSchemasResp

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

the class ThriftCLIService method GetSchemas.

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

use of org.apache.hive.service.rpc.thrift.TGetSchemasResp 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 3 with TGetSchemasResp

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

TGetSchemasResp (org.apache.hive.service.rpc.thrift.TGetSchemasResp)3 TException (org.apache.thrift.TException)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 OperationHandle (org.apache.hive.service.cli.OperationHandle)2 TGetSchemasReq (org.apache.hive.service.rpc.thrift.TGetSchemasReq)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