Reputation: 762
I am referring to Jobs: insert page and trying to get errors using the response object. But response.getStatus().getErrorResult() is always return null even load is unsuccessful. How to extract errors
Upvotes: 0
Views: 215
Reputation: 762
Posting the code for Mikhail's answer,
JobReference jobRef = insert.execute().getJobReference();
System.out.println("Job ID is: " + jobRef.getJobId());
Boolean Run_Status = true;
while (Run_Status) {
Job pollJob = bigquery.jobs().get(projectId, jobRef.getJobId()).execute();
System.out.println("Job status: " + pollJob.getStatus().getState());
if (pollJob.getStatus().getState().equals("DONE")) {
System.out.println(pollJob.getStatus().getErrors());
Run_Status = false;
}
Thread.sleep(1000);
}
Upvotes: 0
Reputation: 173141
From response - you should extract jobId and then use Jobs: get to get status.state of the job. Here you can see if job completed (DONE) or not yet (PENDING or RUNNING), so do this till it is completed and when it is - you can look into status.errorResult for last error or into status.errors for all errors encountered during the running of the job
Upvotes: 2