Database Reference
In-Depth Information
Chapter 7
Running Queries
This chapter describes how to run queries in BigQuery—from how to send
the API requests to how to construct valid queries in the BigQuery variant of
SQL. The chapter is divided into two sections: query API and query language.
The query API section describes the mechanics of how to run queries. If you
do not intend to write code to interact with the BigQuery API, you might want
to skim this section rather than skip it completely; it has information about
what is possible via the underlying API, which might come in handy even if
you're going to use only a web interface or command-line client to interact
with BigQuery.
The query language section describes the features of BigQuery SQL. It
assumes some familiarity with writing SQL queries and does not attempt to
be an in-depth query reference. It does, however, walk through simple query
creation and focus on differences between BigQuery and standard SQL.
After reading this chapter you should know everything you need to know to
construct and run simple queries in BigQuery. Understanding how the query
engine works at a high level is key to getting the most out of BigQuery queries.
For this reason, more advanced query topics are deferred until Chapter 10,
“Advanced Queries,” after the query architecture has been explained.
BigQuery Query API
As discussed in Chapter 5, “Talking to the BigQuery API,” all BigQuery
queries are jobs. Because they are jobs, they execute asynchronously; you can
decouple the act of starting a query from fetching results. You can also see
which queries you've already run and fetch the results in multiple pages.
Another salient feature of query jobs helps with reading query results: All
query results are saved in a BigQuery table. This enables you to interact with
query results the same way you would read any other table. You can copy
the query result table, export it to Google Cloud Storage, and run queries
against the query results themselves. Query result tables are discussed more
thoroughly in the “Query Result Tables” section later in this chapter.
Search WWH ::




Custom Search