Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Job retry solution (client.create_job) is broken #297

Description

@bhtucker

A solution was implemented in #71 but is now broken.

This is not caught by unit tests because the failure is within a mocked interface.

Original issue: #14

Environment details

  • Linux
  • Python 3.6, 3.7
  • Client version 1.25 - 2.0.0

Steps to reproduce

Run the code in the unit tests without mocks; rather than failing for nonexistent/unauthorized project/dataset (as you would expect), it fails with an AttributeError.:

Code example

configuration = {
"load": {
"destinationTable": {
"projectId": 'anyproject',
"datasetId": 'anydataset',
"tableId": "source_table",
},
"sourceUris": ["gs://test_bucket/src_object*"],
}
}
bqclient.create_job(configuration)

Stack trace

Fails with:

~/python/lib/python3.7/site-packages/google/cloud/bigquery/client.py in create_job(self, job_config, retry)
1619 source_uris = _get_sub_prop(job_config, ["load", "sourceUris"])
1620 return self.load_table_from_uri(
-> 1621 source_uris, destination, job_config=load_job_config, retry=retry
1622 )
1623 elif "copy" in job_config:
~/python/lib/python3.7/site-packages/google/cloud/bigquery/client.py in load_table_from_uri(self, source_uris, destination, job_id, job_id_prefix, location, project, job_config, retry, timeout)
1967 1968 load_job = job.LoadJob(job_ref, source_uris, destination, self, job_config)
-> 1969 load_job._begin(retry=retry, timeout=timeout)
1970 1971 return load_job
~/python/lib/python3.7/site-packages/google/cloud/bigquery/job.py in _begin(self, client, retry, timeout)
643 method="POST",
644 path=path,
--> 645 data=self.to_api_repr(),
646 timeout=timeout,
647 )
~/python/lib/python3.7/site-packages/google/cloud/bigquery/job.py in to_api_repr(self)
1694 )
1695 _helpers._set_sub_prop(
-> 1696 configuration, ["load", "destinationTable"], self.destination.to_api_repr()
1697 )
1698 AttributeError: 'dict' object has no attribute 'to_api_repr'

As you can see here, the mocked client method load_table_from_uri is where the traceback begins.

The destination must be coerced to a TableRef before calling this method.

Metadata

Metadata

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions