Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nbali opened this issue Feb 12, 2025 · 0 comments · May be fixed by #3673
Open

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

nbali opened this issue Feb 12, 2025 · 0 comments · May be fixed by #3673
Assignees
Labels
api: bigquery Issues related to the googleapis/java-bigquery API.

Comments

@nbali
Copy link

nbali commented Feb 12, 2025

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());
  }
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/java-bigquery API. label Feb 12, 2025
nbali added a commit to nbali/java-bigquery that referenced this issue Feb 12, 2025
…ob.isDone() calls first to avoid remote calls
@nbali nbali linked a pull request Feb 12, 2025 that will close this issue
4 tasks
@PhongChuong PhongChuong self-assigned this Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/java-bigquery API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants