Database Reference
In-Depth Information
start with a job that has an invalid configuration due to missing permissions.
For example, attempt to load some data into the BigQuery public samples
dataset:
load_config['destinationTable'] = {
'projectId': 'publicdata',
'datasetId': 'samples',
'tableId': 'mypersonaltable'
}
Unless you have somehow gotten write access to the BigQuery samples
dataset, you should see the script report that the job failed. The code listing
you have been using for all the examples in this chapter supports reporting
the errors and checking the overall success status of the job.
for err in result['status'].get('errors', []):
print json.dumps(err, indent=2)
if 'errorResult' in result['status']:
print 'FAILED'
print json.dumps(result['status']['errorResult'],
indent=2)
else:
print 'SUCCESS'
In this snippet the for-loop prints out the contents of the errors (and
warnings) list. The conditional is checking for the presence of the
errorResult field to report whether the job succeeded or failed. The job
you just ran ended up in the done state with errorResult present, so the
final lines of output indicate the job failed.
FAILED
{
"reason": "accessDenied",
"message": "Access Denied: Table
publicdata:samples.mypersonaltable:
CREATE_TABLE"
}
Search WWH ::




Custom Search