Search in sources :

Example 1 with TGetTablesResp

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

the class HiveDatabaseMetaData method getTables.

public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
    TGetTablesResp getTableResp;
    if (schemaPattern == null) {
        // if schemaPattern is null it means that the schemaPattern value should not be used to narrow the search
        schemaPattern = "%";
    }
    TGetTablesReq getTableReq = new TGetTablesReq(sessHandle);
    getTableReq.setTableName(tableNamePattern);
    if (types != null) {
        getTableReq.setTableTypes(Arrays.asList(types));
    }
    getTableReq.setSchemaName(schemaPattern);
    try {
        getTableResp = client.GetTables(getTableReq);
    } catch (TException e) {
        throw new SQLException(e.getMessage(), "08S01", e);
    }
    Utils.verifySuccess(getTableResp.getStatus());
    return new HiveQueryResultSet.Builder(connection).setClient(client).setSessionHandle(sessHandle).setStmtHandle(getTableResp.getOperationHandle()).build();
}
Also used : TException(org.apache.thrift.TException) TGetTablesResp(org.apache.hive.service.rpc.thrift.TGetTablesResp) SQLException(java.sql.SQLException) TGetTablesReq(org.apache.hive.service.rpc.thrift.TGetTablesReq)

Example 2 with TGetTablesResp

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

the class ThriftCLIService method GetTables.

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

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

the class ThriftCLIServiceClient method getTables.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getTables(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String, java.lang.String, java.util.List)
   */
@Override
public OperationHandle getTables(SessionHandle sessionHandle, String catalogName, String schemaName, String tableName, List<String> tableTypes) throws HiveSQLException {
    try {
        TGetTablesReq req = new TGetTablesReq(sessionHandle.toTSessionHandle());
        req.setTableName(tableName);
        req.setTableTypes(tableTypes);
        req.setSchemaName(schemaName);
        TGetTablesResp resp = cliService.GetTables(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 : TGetTablesResp(org.apache.hive.service.rpc.thrift.TGetTablesResp) TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetTablesReq(org.apache.hive.service.rpc.thrift.TGetTablesReq) 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

TGetTablesResp (org.apache.hive.service.rpc.thrift.TGetTablesResp)3 TException (org.apache.thrift.TException)3 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 OperationHandle (org.apache.hive.service.cli.OperationHandle)2 TGetTablesReq (org.apache.hive.service.rpc.thrift.TGetTablesReq)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 TOperationHandle (org.apache.hive.service.rpc.thrift.TOperationHandle)1 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)1