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);
}
}
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);
}
Aggregations