Search in sources :

Example 1 with TGetColumnsResp

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

the class ThriftCLIService method GetColumns.

@Override
public TGetColumnsResp GetColumns(TGetColumnsReq req) throws TException {
    TGetColumnsResp resp = new TGetColumnsResp();
    try {
        OperationHandle opHandle = cliService.getColumns(new SessionHandle(req.getSessionHandle()), req.getCatalogName(), req.getSchemaName(), req.getTableName(), req.getColumnName());
        resp.setOperationHandle(opHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.error("Failed to get column types [request: {}]", req, e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) TGetColumnsResp(org.apache.hive.service.rpc.thrift.TGetColumnsResp) ServiceException(org.apache.hive.service.ServiceException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) LoginException(javax.security.auth.login.LoginException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException)

Example 2 with TGetColumnsResp

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

the class ThriftCLIServiceClient method getColumns.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getColumns(org.apache.hive.service.cli.SessionHandle)
   */
@Override
public OperationHandle getColumns(SessionHandle sessionHandle, String catalogName, String schemaName, String tableName, String columnName) throws HiveSQLException {
    try {
        TGetColumnsReq req = new TGetColumnsReq();
        req.setSessionHandle(sessionHandle.toTSessionHandle());
        req.setCatalogName(catalogName);
        req.setSchemaName(schemaName);
        req.setTableName(tableName);
        req.setColumnName(columnName);
        TGetColumnsResp resp = cliService.GetColumns(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) TGetColumnsReq(org.apache.hive.service.rpc.thrift.TGetColumnsReq) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TOperationHandle(org.apache.hive.service.rpc.thrift.TOperationHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) TGetColumnsResp(org.apache.hive.service.rpc.thrift.TGetColumnsResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 3 with TGetColumnsResp

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

the class HiveDatabaseMetaData method getColumns.

public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
    TGetColumnsResp colResp;
    TGetColumnsReq colReq = new TGetColumnsReq();
    colReq.setSessionHandle(sessHandle);
    colReq.setCatalogName(catalog);
    colReq.setSchemaName(schemaPattern);
    colReq.setTableName(tableNamePattern);
    colReq.setColumnName(columnNamePattern);
    try {
        colResp = client.GetColumns(colReq);
    } catch (TException e) {
        throw new SQLException(e.getMessage(), "08S01", e);
    }
    Utils.verifySuccess(colResp.getStatus());
    // build the resultset from response
    return new HiveQueryResultSet.Builder(connection).setClient(client).setStmtHandle(colResp.getOperationHandle()).build();
}
Also used : TException(org.apache.thrift.TException) SQLException(java.sql.SQLException) TGetColumnsReq(org.apache.hive.service.rpc.thrift.TGetColumnsReq) TGetColumnsResp(org.apache.hive.service.rpc.thrift.TGetColumnsResp)

Aggregations

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