Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-CloudSufi committed Jan 28, 2025
1 parent 554f6f5 commit a1d1fdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void run(ActionContext context) {
try {
queryJob.waitFor();
} catch (BigQueryException | InterruptedException e) {
String errorMessage = String.format("The query job was interrupted, %s: %s",
String errorMessage = String.format("The bigquery query job failed, %s: %s",
e.getClass().getName(), e.getMessage());
if (e instanceof BigQueryException) {
throw BigQueryErrorUtil.getProgramFailureException(errorMessage,
Expand All @@ -115,10 +115,12 @@ public void run(ActionContext context) {

// Check for errors
if (queryJob.getStatus().getError() != null) {
String error = queryJob.getStatus().getExecutionErrors().toString();
String errorReason = String.format("The bigquery job failed with reason: %s",
queryJob.getStatus().getError().getReason());
ErrorType type = BigQueryErrorUtil.getErrorType(queryJob.getStatus().getError().getReason());
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, type, true, null);
throw ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorReason, errorReason, type,
true, null);
}
TableResult queryResults;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void run(ActionContext context) {
try {
executeQuery(bigQuery, queryConfig, context);
} catch (Exception e) {
String errorMessage = String.format("Failed to execute query, %s: %s",
String errorMessage = String.format("The bigquery query execution failed, %s: %s",
e.getClass().getName(), e.getMessage());
String errorReason = null;
if (e instanceof BigQueryException) {
Expand All @@ -195,10 +195,10 @@ protected void executeQueryWithExponentialBackoff(BigQuery bigQuery,
try {
Failsafe.with(getRetryPolicy()).run(() -> executeQuery(bigQuery, queryConfig, context));
} catch (FailsafeException e) {
String errorReason = String.format("Failed to execute query with message: %s",
String errorReason = String.format("The bigquery query execution failed with message: %s",
e.getMessage());
if (e.getCause() != null) {
errorReason = String.format("Failed to execute query with message: %s",
errorReason = String.format("The bigquery query execution failed with message: %s",
e.getCause().getMessage());
}
throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(
Expand Down Expand Up @@ -234,8 +234,8 @@ private void executeQuery(BigQuery bigQuery, QueryJobConfiguration queryConfig,
// Wait for the query to complete
queryJob = queryJob.waitFor();
} catch (BigQueryException | InterruptedException e) {
String errorMessage = String.format("Failed to execute query, %s: %s", e.getClass().getName(),
e.getMessage());
String errorMessage = String.format("The bigquery query execution failed, %s: %s",
e.getClass().getName(), e.getMessage());
if (e instanceof BigQueryException) {
LOG.error("The query job {} failed. Error: {}", jobId.getJob(),
((BigQueryException) e).getError().getMessage());
Expand All @@ -255,11 +255,14 @@ private void executeQuery(BigQuery bigQuery, QueryJobConfiguration queryConfig,
if (queryJob.getStatus().getError() != null) {
// You can also look at queryJob.getStatus().getExecutionErrors() for all
// errors, not just the latest one.
LOG.error("The query job {} failed. Error: {}", jobId.getJob(), queryJob.getStatus().getError());
LOG.error(
String.format("The query job %s failed with error %s and reason %s.", jobId.getJob(),
queryJob.getStatus().getError().getReason(), queryJob.getStatus().getError()));
if (RETRY_ON_REASON.contains(queryJob.getStatus().getError().getReason())) {
throw new BigQueryJobExecutionException(queryJob.getStatus().getError().getMessage());
}
String error = String.format("Failed to execute query with reason: %s and message: %s",
String error = String.format(
"The bigquery query execution failed with reason: %s and message: %s",
queryJob.getStatus().getError().getReason(),
queryJob.getStatus().getError().getMessage());
ErrorType type = BigQueryErrorUtil.getErrorType(queryJob.getStatus().getError().getReason());
Expand Down Expand Up @@ -727,7 +730,7 @@ public void validateSQLSyntax(FailureCollector failureCollector, BigQuery bigQue
errorMessage = String.format(
"Resource was not found. Please verify the resource name. If the resource will be "
+ "created at runtime, then update to use a macro for the resource name. "
+ "Error message received was %s, %s", e.getClass().getName(), e.getMessage());
+ "Error message received was %s: %s", e.getClass().getName(), e.getMessage());
} else {
errorMessage = e.getMessage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public class BigQueryErrorUtil {

//https://cloud.google.com/bigquery/docs/error-messages#errortable
// https://cloud.google.com/bigquery/docs/error-messages#errortable
private static final Map<String, ErrorType> ERROR_REASON_TO_ERROR_TYPE = new HashMap<>();

static {
Expand Down

0 comments on commit a1d1fdf

Please sign in to comment.