|
25 | 25 | import com.google.api.client.util.Sleeper; |
26 | 26 | import com.google.api.services.bigquery.model.Clustering; |
27 | 27 | import com.google.api.services.bigquery.model.Dataset; |
| 28 | +import com.google.api.services.bigquery.model.ErrorProto; |
28 | 29 | import com.google.api.services.bigquery.model.Job; |
29 | 30 | import com.google.api.services.bigquery.model.JobReference; |
30 | 31 | import com.google.api.services.bigquery.model.JobStatus; |
@@ -205,6 +206,7 @@ static class PendingJob implements Serializable { |
205 | 206 | void runJob() throws IOException { |
206 | 207 | ++currentAttempt; |
207 | 208 | if (!shouldRetry()) { |
| 209 | + logBigQueryError(lastJobAttempted); |
208 | 210 | throw new RuntimeException( |
209 | 211 | String.format( |
210 | 212 | "Failed to create job with prefix %s, " |
@@ -281,6 +283,21 @@ boolean pollJob() throws IOException { |
281 | 283 | boolean shouldRetry() { |
282 | 284 | return currentAttempt < maxRetries + 1; |
283 | 285 | } |
| 286 | + |
| 287 | + void logBigQueryError(@Nullable Job job) { |
| 288 | + if (job == null || !parseStatus(job).equals(Status.FAILED)) { |
| 289 | + return; |
| 290 | + } |
| 291 | + |
| 292 | + List<ErrorProto> jobErrors = job.getStatus().getErrors(); |
| 293 | + String finalError = job.getStatus().getErrorResult().getMessage(); |
| 294 | + String causativeError = |
| 295 | + jobErrors != null && !jobErrors.isEmpty() |
| 296 | + ? String.format(" due to: %s", jobErrors.get(jobErrors.size() - 1).getMessage()) |
| 297 | + : ""; |
| 298 | + |
| 299 | + LOG.error(String.format("BigQuery Error : %s %s", finalError, causativeError)); |
| 300 | + } |
284 | 301 | } |
285 | 302 |
|
286 | 303 | static class RetryJobId implements Serializable { |
|
0 commit comments