Search in sources :

Example 1 with TGetColumnsReq

use of org.apache.hive.service.rpc.thrift.TGetColumnsReq 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) 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 2 with TGetColumnsReq

use of org.apache.hive.service.rpc.thrift.TGetColumnsReq 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).setSessionHandle(sessHandle).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

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