use of io.prestosql.spi.ErrorCode in project hetu-core by openlookeng.
the class QueryStateMachine method getBasicQueryInfo.
public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageStats> rootStage) {
// Query state must be captured first in order to provide a
// correct view of the query. For example, building this
// information, the query could finish, and the task states would
// never be visible.
QueryState state = queryState.get();
ErrorCode errorCode = null;
if (state == FAILED) {
ExecutionFailureInfo localFailureCause = this.failureCause.get();
if (localFailureCause != null) {
errorCode = localFailureCause.getErrorCode();
}
}
BasicStageStats stageStats = rootStage.orElse(EMPTY_STAGE_STATS);
BasicQueryStats queryStats = new BasicQueryStats(queryStateTimer.getCreateTime(), getEndTime().orElse(null), queryStateTimer.getQueuedTime(), queryStateTimer.getElapsedTime(), queryStateTimer.getExecutionTime(), stageStats.getTotalDrivers(), stageStats.getQueuedDrivers(), stageStats.getRunningDrivers(), stageStats.getCompletedDrivers(), stageStats.getRawInputDataSize(), stageStats.getRawInputPositions(), stageStats.getCumulativeUserMemory(), stageStats.getUserMemoryReservation(), stageStats.getTotalMemoryReservation(), succinctBytes(getPeakUserMemoryInBytes()), succinctBytes(getPeakTotalMemoryInBytes()), stageStats.getTotalCpuTime(), stageStats.getTotalScheduledTime(), stageStats.isFullyBlocked(), stageStats.getBlockedReasons(), stageStats.getProgressPercentage());
return new BasicQueryInfo(queryId, session.toSessionRepresentation(), Optional.of(resourceGroup), state, memoryPool.get().getId(), stageStats.isScheduled(), self, query, preparedQuery, queryStats, errorCode == null ? null : errorCode.getType(), errorCode);
}
use of io.prestosql.spi.ErrorCode in project hetu-core by openlookeng.
the class Query method toQueryError.
private static QueryError toQueryError(QueryInfo queryInfo) {
QueryState state = queryInfo.getState();
if (state != FAILED) {
return null;
}
ExecutionFailureInfo executionFailure;
if (queryInfo.getFailureInfo() != null) {
executionFailure = queryInfo.getFailureInfo();
} else {
log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state);
executionFailure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state)));
}
FailureInfo failure = executionFailure.toFailureInfoWithoutStack();
ErrorCode errorCode;
if (queryInfo.getErrorCode() != null) {
errorCode = queryInfo.getErrorCode();
} else {
errorCode = GENERIC_INTERNAL_ERROR.toErrorCode();
log.warn("Failed query %s has no error code", queryInfo.getQueryId());
}
return new QueryError(firstNonNull(failure.getMessage(), "Internal error"), null, errorCode.getCode(), errorCode.getName(), executionFailure.getSemanticErrorCode().map(SemanticErrorCode::name), errorCode.getType().toString(), failure.getErrorLocation(), failure);
}
Aggregations