Database Reference
In-Depth Information
drop-down menu, and then click the Play button. This runs the query and
writes the results to the logger.
If you open the log (under the View menu), you should see both the query
and the results. If there was an error, you can see that in the log or in the
execution transcript (also on the View menu). If you need more debugging
support, if you use the bug icon instead of the play icon, you can step
through the script and set breakpoints, and so on.
Writing Query Results to a Spreadsheet
You now have all the pieces you need to write a script that lets you send
arbitrary queries to BigQuery and write the results to a spreadsheet. Listing
12.9 lets you run queries and writes the results to a Query Results sheet in
the spreadsheet.
Listing
12.9 :
Running
a
query
and
writing
the
results
to
a
spreadsheet (query.gs)
/**
* BigQuery query script.
* This script installs a 'BigQuery' menu in your
spreadsheet that
* allow you to run queries.
*
* To use, first enter your project ID in a
* cell of your choosing, then with that cell
selected, select the
* 'Set project' item from the BigQuery menu. This
will save your
* project ID as a user property so you won't need to
set it again.
* You can delete the cell where you had entered the
project ID.
* To run a query, write a query in any cell or range
of cells.
* Select those cells, and then pick 'Run Query' from
the BigQuery
* menu. This will run the query you've selected and
add the outputs
* to a new sheet called 'Query Results'. If this
 
 
 
 
Search WWH ::




Custom Search