Skip to content

Potentially unnecessary bigquery.getJob() calls in Job.isDone() #3672

@nbali

Description

@nbali

Is your feature request related to a problem? Please describe.
Even if the Job object we have contains that the job is "done" we do a remote call for no reason.

Describe the solution you'd like
I would first check the current state, and only do a remote call if needed, or the current state contains "false".

Describe alternatives you've considered

Additional context

Instead of

https://github.com/googleapis/java-bigquery/blob/009b9a2b3940ab66220e68ddd565710b8552cc45/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Job.java#L194C4-L198

  public boolean isDone() {
    checkNotDryRun("isDone");
    Job job = bigquery.getJob(getJobId(), JobOption.fields(BigQuery.JobField.STATUS));
    return job == null || JobStatus.State.DONE.equals(job.getStatus().getState());
  }

do this

  public boolean isDone() {
    checkNotDryRun("isDone");
    if (getStatus() != null && JobStatus.State.DONE.equals(getStatus().getState()) {
      return true;
    }
    Job job = bigquery.getJob(getJobId(), JobOption.fields(BigQuery.JobField.STATUS));
    return job == null || JobStatus.State.DONE.equals(job.getStatus().getState());
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigqueryIssues related to the googleapis/java-bigquery API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions