Database Reference
In-Depth Information
After you start the job via Jobs.insert() , you can still call
Jobs.getQueryResults() to read the results. This listing shows the
lower-level methods that demonstrate what Jobs.getQueryResults()
actually does behind the scenes.
Query API Features
Now that you have seen the basic mechanics of the query API, consider some
of the more advanced features available. You can access these features, for
the most part, in the BigQuery web interface or via the bq command-line
tool. We show the Python code in order to demonstrate the raw API settings.
Query Result Tables
All query results are first-class tables in BigQuery; whether you use the
Jobs.query() or the Jobs.insert() method to run a query, your query
results are always tables. This means you can list them, copy them, get their
schema, and run queries against them. Query result tables have some special
properties, which are described in this section.
Anonymous Tables
When you don't explicitly provide a name for the destination table,
BigQuery generates a unique table name for the result. These unique tables
are called anonymous tables because their names are unimportant. The
name of the table is added to the job configuration in the job resource;
you can find it by calling Jobs.get() . Here is an example of using the
Jobs.query() method to run a query and then Jobs.get() to find the
anonymous table name:
>>> response = service.jobs().query(
projectId=project_id ,
body={'query': 'SELECT 42'}).execute()
>>> job =
service.jobs().get(**response['jobReference']).execute()
>>> destination_table=job['configuration']['query']['destinationTable']
>>> pprint.pprint(destination_table)
{u'datasetId':
u'_0e32b38e1117b2fcea992287c138bd53acfff7cc',
u'projectId': u'bigquery-e2e',
Search WWH ::




Custom Search