Skip to content

Code snippet error - response.getResult returns nullptr if job not completed. #570

Closed

Description

@cobookman

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/bigquery/cloud-client/src/main/java/com/example/bigquery/SimpleApp.java#L53

Did you change the file? If so, how?

while (!response.jobCompleted()) {
  Thread.sleep(1000);
  response = bigquery.getQueryResults(response.getJobId());
}
List<BigQueryError> executionErrors = response.getExecutionErrors();
// look for errors in executionErrors
QueryResult result = response.getResult();

Describe the issue

response.getResult() will return with a nullptr if the job has not completed yet. It does not block until job is completed.

http://googlecloudplatform.github.io/google-cloud-java/0.5.0/apidocs/com/google/cloud/bigquery/QueryResponse.html#getResult()

Activity

  1. lesv commented on Mar 19, 2017

    @lesv
    Contributor

    @tswast PTAL

  2. tswast commented on Mar 20, 2017

    @tswast
    Contributor

    The behavior of the .query() method is confusing since it can sometimes return results, and sometimes you have to poll as you describe.

    You're correct that we should always poll in the samples since that is likely to be needed. I'll update this one today.

    Related: googleapis/google-cloud-java#1588 I've proposed to the client library team that we don't use .query() without an explicit JobID anywhere.

  3. added a commit that references this issue on Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo