Search in sources :

Example 6 with TableSchema

use of org.apache.hive.service.cli.TableSchema in project hive by apache.

the class ThriftCLIServiceClient method getResultSetMetadata.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getResultSetMetadata(org.apache.hive.service.cli.OperationHandle)
   */
@Override
public TableSchema getResultSetMetadata(OperationHandle opHandle) throws HiveSQLException {
    try {
        TGetResultSetMetadataReq req = new TGetResultSetMetadataReq(opHandle.toTOperationHandle());
        TGetResultSetMetadataResp resp = cliService.GetResultSetMetadata(req);
        checkStatus(resp.getStatus());
        return new TableSchema(resp.getSchema());
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TGetResultSetMetadataReq(org.apache.hive.service.rpc.thrift.TGetResultSetMetadataReq) TableSchema(org.apache.hive.service.cli.TableSchema) TGetResultSetMetadataResp(org.apache.hive.service.rpc.thrift.TGetResultSetMetadataResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 7 with TableSchema

use of org.apache.hive.service.cli.TableSchema in project hive by apache.

the class HiveCommandOperation method runInternal.

@Override
public void runInternal() throws HiveSQLException {
    setState(OperationState.RUNNING);
    try {
        String command = getStatement().trim();
        String[] tokens = statement.split("\\s");
        String commandArgs = command.substring(tokens[0].length()).trim();
        CommandProcessorResponse response = commandProcessor.run(commandArgs);
        int returnCode = response.getResponseCode();
        if (returnCode != 0) {
            throw toSQLException("Error while processing statement", response);
        }
        Schema schema = response.getSchema();
        if (schema != null) {
            setHasResultSet(true);
            resultSchema = new TableSchema(schema);
        } else {
            setHasResultSet(false);
            resultSchema = new TableSchema();
        }
        if (response.getConsoleMessages() != null) {
            // Propagate processor messages (if any) to beeline or other client.
            OperationLog ol = OperationLog.getCurrentOperationLog();
            if (ol != null) {
                for (String consoleMsg : response.getConsoleMessages()) {
                    ol.writeOperationLog(LoggingLevel.EXECUTION, consoleMsg + "\n");
                }
            }
        }
    } catch (HiveSQLException e) {
        setState(OperationState.ERROR);
        throw e;
    } catch (Exception e) {
        setState(OperationState.ERROR);
        throw new HiveSQLException("Error running query: " + e.toString(), e);
    }
    setState(OperationState.FINISHED);
}
Also used : TableSchema(org.apache.hive.service.cli.TableSchema) CommandProcessorResponse(org.apache.hadoop.hive.ql.processors.CommandProcessorResponse) TableSchema(org.apache.hive.service.cli.TableSchema) Schema(org.apache.hadoop.hive.metastore.api.Schema) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationLog(org.apache.hadoop.hive.ql.session.OperationLog) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

TableSchema (org.apache.hive.service.cli.TableSchema)7 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)6 TGetResultSetMetadataResp (org.apache.hive.service.rpc.thrift.TGetResultSetMetadataResp)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 OperationLog (org.apache.hadoop.hive.ql.session.OperationLog)2 TGetResultSetMetadataReq (org.apache.hive.service.rpc.thrift.TGetResultSetMetadataReq)2 TException (org.apache.thrift.TException)2 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 UnknownHostException (java.net.UnknownHostException)1 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 Pattern (java.util.regex.Pattern)1 LoginException (javax.security.auth.login.LoginException)1 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)1