Skip to content

[BigQuery] Feature Request - An easy way to get a QueryResults from a QueryJob #2083

@tswast

Description

@tswast

Problem:

There isn't an easy way to fetch the row results of a client.run_async_query(job_id, query) call.

I have to do some yucky stuff to get it to work in a sample I'm working on.

client = bigquery.Client()
query_job = client.run_async_query(str(uuid.uuid4()), query)
query_job.use_legacy_sql = False
query_job.begin()

wait_for_job(query_job)

query_results = bigquery.query.QueryResults('', client)
query_results._properties['jobReference'] = {
    'jobId': query_job.name,
    'projectId': query_job.project
}

Possible Solutions:

  • Modify constructor for QueryResults or add a class function to take an optional job object.
  • Add a method to QueryJob get_query_results() that does this same yuckiness (modifying the internal _properties)

I'm sure there are other solutions, too, which is why I'm asking for input rather than going off and trying to fix right away.

Reference:

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions