|
35 | 35 | import com.google.api.services.bigquery.model.Job; |
36 | 36 | import com.google.api.services.bigquery.model.JobList; |
37 | 37 | import com.google.api.services.bigquery.model.JobReference; |
| 38 | +import com.google.api.services.bigquery.model.JobStatus; |
38 | 39 | import com.google.api.services.bigquery.model.QueryRequest; |
39 | 40 | import com.google.api.services.bigquery.model.QueryResponse; |
40 | 41 | import com.google.api.services.bigquery.model.Table; |
@@ -220,8 +221,9 @@ public Tuple<String, Iterable<Table>> listTables(String datasetId, Map<Option, ? |
220 | 221 | .setMaxResults(MAX_RESULTS.getLong(options)) |
221 | 222 | .setPageToken(PAGE_TOKEN.getString(options)) |
222 | 223 | .execute(); |
| 224 | + Iterable<TableList.Tables> tables = tableList.getTables(); |
223 | 225 | return Tuple.of(tableList.getNextPageToken(), |
224 | | - Iterables.transform(tableList.getTables(), |
| 226 | + Iterables.transform(tables != null ? tables : ImmutableList.<TableList.Tables>of(), |
225 | 227 | new Function<TableList.Tables, Table>() { |
226 | 228 | @Override |
227 | 229 | public Table apply(TableList.Tables f) { |
@@ -350,11 +352,19 @@ public Tuple<String, Iterable<Job>> listJobs(Map<Option, ?> options) throws BigQ |
350 | 352 | .setPageToken(PAGE_TOKEN.getString(options)) |
351 | 353 | .setProjection(DEFAULT_PROJECTION) |
352 | 354 | .execute(); |
| 355 | + Iterable<JobList.Jobs> jobs = jobsList.getJobs(); |
353 | 356 | return Tuple.of(jobsList.getNextPageToken(), |
354 | | - Iterables.transform(jobsList.getJobs(), |
| 357 | + Iterables.transform(jobs != null ? jobs : ImmutableList.<JobList.Jobs>of(), |
355 | 358 | new Function<JobList.Jobs, Job>() { |
356 | 359 | @Override |
357 | 360 | public Job apply(JobList.Jobs f) { |
| 361 | + JobStatus statusPb = f.getStatus() != null ? f.getStatus() : new JobStatus(); |
| 362 | + if (statusPb.getState() == null) { |
| 363 | + statusPb.setState(f.getState()); |
| 364 | + } |
| 365 | + if (statusPb.getErrorResult() == null) { |
| 366 | + statusPb.setErrorResult(f.getErrorResult()); |
| 367 | + } |
358 | 368 | return new Job() |
359 | 369 | .setConfiguration(f.getConfiguration()) |
360 | 370 | .setId(f.getId()) |
|
0 commit comments