@JsonCreator public ExecutionFailureInfo( @JsonProperty("type") String type, @JsonProperty("message") String message, @JsonProperty("cause") ExecutionFailureInfo cause, @JsonProperty("suppressed") List<ExecutionFailureInfo> suppressed, @JsonProperty("stack") List<String> stack, @JsonProperty("errorLocation") @Nullable ErrorLocation errorLocation, @JsonProperty("errorCode") @Nullable ErrorCode errorCode) { requireNonNull(type, "type is null"); requireNonNull(suppressed, "suppressed is null"); requireNonNull(stack, "stack is null"); this.type = type; this.message = message; this.cause = cause; this.suppressed = ImmutableList.copyOf(suppressed); this.stack = ImmutableList.copyOf(stack); this.errorLocation = errorLocation; this.errorCode = errorCode; }
@Nullable private static ErrorCode toErrorCode(@Nullable Throwable throwable) { if (throwable == null) { return null; } if (throwable instanceof PrestoException) { return ((PrestoException) throwable).getErrorCode(); } if (throwable instanceof Failure && ((Failure) throwable).getErrorCode() != null) { return ((Failure) throwable).getErrorCode(); } if (throwable instanceof ParsingException || throwable instanceof SemanticException) { return SYNTAX_ERROR.toErrorCode(); } if (throwable.getCause() != null) { return toErrorCode(throwable.getCause()); } return INTERNAL_ERROR.toErrorCode(); }
private static boolean shouldAddStackTrace(Exception e) { if (e instanceof PrestoException) { ErrorCode errorCode = ((PrestoException) e).getErrorCode(); if (EXPECTED_ERRORS.contains(errorCode)) { return false; } } return true; }
private static QueryError toQueryError(QueryInfo queryInfo) { FailureInfo failure = queryInfo.getFailureInfo(); if (failure == null) { QueryState state = queryInfo.getState(); if ((!state.isDone()) || (state == QueryState.FINISHED)) { return null; } log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state); failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo(); } ErrorCode errorCode; if (queryInfo.getErrorCode() != null) { errorCode = queryInfo.getErrorCode(); } else { errorCode = INTERNAL_ERROR.toErrorCode(); log.warn("Failed query %s has no error code", queryInfo.getQueryId()); } return new QueryError( failure.getMessage(), null, errorCode.getCode(), errorCode.getName(), toErrorType(errorCode.getCode()).toString(), failure.getErrorLocation(), failure); }
public void assertInvalidFunction(String projection, ErrorCode errorCode) { try { assertFunction(projection, UNKNOWN, null); fail("Expected error " + errorCode + " from " + projection); } catch (PrestoException e) { assertEquals(e.getErrorCode(), errorCode); } }
@Nullable @JsonProperty public ErrorCode getErrorCode() { return errorCode; }
@JsonCreator public QueryInfo( @JsonProperty("queryId") QueryId queryId, @JsonProperty("session") SessionRepresentation session, @JsonProperty("state") QueryState state, @JsonProperty("memoryPool") MemoryPoolId memoryPool, @JsonProperty("scheduled") boolean scheduled, @JsonProperty("self") URI self, @JsonProperty("fieldNames") List<String> fieldNames, @JsonProperty("query") String query, @JsonProperty("queryStats") QueryStats queryStats, @JsonProperty("setSessionProperties") Map<String, String> setSessionProperties, @JsonProperty("resetSessionProperties") Set<String> resetSessionProperties, @JsonProperty("startedTransactionId") Optional<TransactionId> startedTransactionId, @JsonProperty("clearTransactionId") boolean clearTransactionId, @JsonProperty("updateType") String updateType, @JsonProperty("outputStage") StageInfo outputStage, @JsonProperty("failureInfo") FailureInfo failureInfo, @JsonProperty("errorCode") ErrorCode errorCode, @JsonProperty("inputs") Set<Input> inputs) { requireNonNull(queryId, "queryId is null"); requireNonNull(session, "session is null"); requireNonNull(state, "state is null"); requireNonNull(self, "self is null"); requireNonNull(fieldNames, "fieldNames is null"); requireNonNull(queryStats, "queryStats is null"); requireNonNull(setSessionProperties, "setSessionProperties is null"); requireNonNull(resetSessionProperties, "resetSessionProperties is null"); requireNonNull(startedTransactionId, "startedTransactionId is null"); requireNonNull(query, "query is null"); requireNonNull(inputs, "inputs is null"); this.queryId = queryId; this.session = session; this.state = state; this.memoryPool = requireNonNull(memoryPool, "memoryPool is null"); this.scheduled = scheduled; this.self = self; this.fieldNames = ImmutableList.copyOf(fieldNames); this.query = query; this.queryStats = queryStats; this.setSessionProperties = ImmutableMap.copyOf(setSessionProperties); this.resetSessionProperties = ImmutableSet.copyOf(resetSessionProperties); this.startedTransactionId = startedTransactionId; this.clearTransactionId = clearTransactionId; this.updateType = updateType; this.outputStage = outputStage; this.failureInfo = failureInfo; this.errorType = errorCode == null ? null : toErrorType(errorCode.getCode()); this.errorCode = errorCode; this.inputs = ImmutableSet.copyOf(inputs); }
Failure(String type, String message, @Nullable ErrorCode errorCode, Failure cause) { super(message, cause, true, true); this.type = requireNonNull(type, "type is null"); this.errorCode = errorCode; }
public ErrorCode getErrorCode() { return errorCode; }
@JsonCreator public BasicQueryInfo( @JsonProperty("queryId") QueryId queryId, @JsonProperty("session") SessionRepresentation session, @JsonProperty("state") QueryState state, @JsonProperty("errorType") ErrorType errorType, @JsonProperty("errorCode") ErrorCode errorCode, @JsonProperty("scheduled") boolean scheduled, @JsonProperty("fullyBlocked") boolean fullyBlocked, @JsonProperty("blockedReasons") Set<BlockedReason> blockedReasons, @JsonProperty("self") URI self, @JsonProperty("query") String query, @JsonProperty("elapsedTime") Duration elapsedTime, @JsonProperty("endTime") DateTime endTime, @JsonProperty("createTime") DateTime createTime, @JsonProperty("runningDrivers") int runningDrivers, @JsonProperty("queuedDrivers") int queuedDrivers, @JsonProperty("completedDrivers") int completedDrivers, @JsonProperty("totalDrivers") int totalDrivers) { this.queryId = requireNonNull(queryId, "queryId is null"); this.session = requireNonNull(session, "session is null"); this.state = requireNonNull(state, "state is null"); this.errorType = errorType; this.errorCode = errorCode; this.scheduled = scheduled; this.fullyBlocked = fullyBlocked; this.blockedReasons = ImmutableSet.copyOf(requireNonNull(blockedReasons, "blockedReasons is null")); this.self = requireNonNull(self, "self is null"); this.query = requireNonNull(query, "query is null"); this.elapsedTime = elapsedTime; this.endTime = endTime; this.createTime = createTime; checkArgument(runningDrivers >= 0, "runningDrivers is less than zero"); this.runningDrivers = runningDrivers; checkArgument(queuedDrivers >= 0, "queuedDrivers is less than zero"); this.queuedDrivers = queuedDrivers; checkArgument(completedDrivers >= 0, "completedDrivers is less than zero"); this.completedDrivers = completedDrivers; checkArgument(totalDrivers >= 0, "totalDrivers is less than zero"); this.totalDrivers = totalDrivers; }
public QueryCompletionEvent( QueryId queryId, String transactionId, String user, String principal, String source, String serverVersion, String environment, String catalog, String schema, String remoteClientAddress, String userAgent, QueryState queryState, URI uri, List<String> fieldNames, String query, Long peakMemoryBytes, DateTime createTime, DateTime executionStartTime, DateTime endTime, Duration queuedTime, Duration analysisTime, Duration distributedPlanningTime, Duration totalSplitWallTime, Duration totalSplitCpuTime, DataSize totalDataSize, Long totalRows, Integer splits, ErrorCode errorCode, String failureType, String failureMessage, String failureTask, String failureHost, String outputStageJson, String failuresJson, String inputsJson, String sessionPropertiesJson) { this.queryId = queryId; this.transactionId = transactionId; this.user = user; this.principal = principal; this.source = source; this.serverVersion = serverVersion; this.environment = environment; this.catalog = catalog; this.schema = schema; this.remoteClientAddress = remoteClientAddress; this.userAgent = userAgent; this.queryState = queryState; this.uri = uri; this.errorCode = errorCode; this.fieldNames = ImmutableList.copyOf(fieldNames); this.peakMemoryBytes = peakMemoryBytes; this.query = query; this.createTime = createTime; this.executionStartTime = executionStartTime; this.endTime = endTime; this.queuedTimeMs = durationToMillis(queuedTime); this.analysisTimeMs = durationToMillis(analysisTime); this.distributedPlanningTimeMs = durationToMillis(distributedPlanningTime); this.totalSplitWallTimeMs = durationToMillis((totalSplitWallTime)); this.totalSplitCpuTimeMs = durationToMillis(totalSplitCpuTime); this.totalBytes = sizeToBytes(totalDataSize); this.totalRows = totalRows; this.splits = splits; this.failureType = failureType; this.failureMessage = failureMessage; this.failureTask = failureTask; this.failureHost = failureHost; this.outputStageJson = outputStageJson; this.failuresJson = failuresJson; this.inputsJson = inputsJson; this.sessionPropertiesJson = sessionPropertiesJson; }