A business question becomes an insight only after a SQL query has resolved it against the trusted source of facts.
On Google Cloud the analytical query engine is BigQuery, and every reporting workflow you build starts with the same primitives: a project, a dataset, a table or view, a query, and a job.
The team that loaded the data in Chapter 1 has finished its work; the analyst now has to phrase the question in SQL, run it efficiently, return only the rows the consumer needs, and persist the output in a form the business can read.
The reason this single bullet of the exam guide carries so much weight is that the same SQL surface drives ad-hoc exploration in the BigQuery Studio editor, scheduled reports backed by destination tables, materialized views that incrementally maintain aggregates, and the SQL embedded inside CREATE MODEL statements covered in section 2.3.
How it works
BigQuery uses GoogleSQL, a dialect that is ANSI 2011 compliant with a wide set of extensions. The execution engine separates compute from storage.
Storage holds columnar Capacitor files in regional or multi-region location, and compute is a distributed query planner that allocates slots, the abstract unit of CPU and memory, on demand.
When you submit a query through the BigQuery Studio web UI, the bq query command, the REST API, a client library, or a JDBC driver, BigQuery:
- creates a query job
- returns a job ID
- plans the query into stages of shuffled work
- runs the stages on a pool of slots
- writes the results to either a temporary anonymous result table or an explicit destination table
Knowing this mental model matters because every cost, every latency, and every quota you will see on the exam is anchored to one of those steps.
The on-demand billing model charges per byte processed across the columns referenced in the query, with a 10 MB minimum per query. Two design choices reduce that number more than anything else:
- only project the columns you need
- prune partitions and clusters at the WHERE clause
A query like SELECT * FROM dataset.events WHERE event_date = '2099-01-01' against a partitioned and clustered table can read kilobytes; the same query without the WHERE predicate reads the entire table. BigQuery validates the cost before execution and returns a dry-run estimate in the UI and in the API response field totalBytesProcessed. Analysts who ship reports without examining the dry-run estimate routinely surprise the finance team.
The reservation model, with editions like Standard, Enterprise, and Enterprise Plus, replaces per-byte billing with autoscaled slot capacity, but on the exam the default assumption for ad-hoc analysis is on-demand.
The result of a query that the analyst wants to keep can be saved in three ways.
- First, the query can write to a destination table set in the job configuration; this turns the query into a tiny ELT step and is how scheduled queries persist their outputs.
- Second, the query can be wrapped in
CREATE TABLE AS SELECTorINSERT INTOfor full programmatic control of the schema and partitioning. - Third, the query can be saved as a view or materialized view.
A standard view stores only the SQL definition and re-executes the query on every reference; a materialized view stores the precomputed aggregate and incrementally maintains it as the base table changes, which is the right structure for a high-traffic dashboard tile that aggregates billions of rows. The materialized view honors most aggregate functions and a defined subset of expressions, and the smart tuning service automatically routes a matching query to the materialized view even when the user query targets the base table.
Anatomy of a BigQuery query that drives a report
The example below answers a concrete business question: which product categories produced the top five revenue contributions for the previous full month, broken down by region, with a year-over-year growth column. The pattern is intentional: a CTE for the current period, a CTE for the prior period, a join on the dimensional grain, and a final projection.
WITH current_period AS (
SELECT
region,
product_category,
SUM(net_revenue) AS revenue_curr
FROM `analytics_prod.fact_orders`
WHERE order_date BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH), MONTH)
AND LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH))
GROUP BY region, product_category
),
prior_period AS (
SELECT
region,
product_category,
SUM(net_revenue) AS revenue_prior
FROM `analytics_prod.fact_orders`
WHERE order_date BETWEEN DATE_TRUNC(DATE_SUB(CURRENT_DATE(), INTERVAL 13 MONTH), MONTH)
AND LAST_DAY(DATE_SUB(CURRENT_DATE(), INTERVAL 13 MONTH))
GROUP BY region, product_category
)
SELECT
c.region,
c.product_category,
c.revenue_curr,
p.revenue_prior,
SAFE_DIVIDE(c.revenue_curr - p.revenue_prior, p.revenue_prior) AS yoy_growth
FROM current_period c
LEFT JOIN prior_period p
USING (region, product_category)
QUALIFY ROW_NUMBER() OVER (PARTITION BY c.region ORDER BY c.revenue_curr DESC) <= 5
ORDER BY c.region, c.revenue_curr DESC;
The query uses three constructs that the exam likes to probe.
SAFE_DIVIDEreturns NULL on division by zero instead of raising an error, which protects scheduled reports from blowing up when a new region has no prior revenue.QUALIFYfilters the result of a window function in a single pass, replacing the older pattern of wrappingROW_NUMBERin an outer subquery.- The date math anchors the comparison to whole months even when the report runs on any day in the month.
Operational SQL: scheduled queries and parameterization
Reports are rarely a single execution; they run on a cadence. BigQuery scheduled queries are a managed feature of the BigQuery Data Transfer Service.
A scheduled query stores the SQL, the destination table, the write disposition, the schedule expression, and the user or service account whose credentials are used to run the job. The schedule supports the cron format and a small set of named cadences.
The two most common exam traps with scheduled queries are credential handling and timezone handling. The scheduled query can run as the user who created it or, far more reliably, as a service account that has bigquery.dataEditor on the destination dataset and bigquery.dataViewer on the source dataset.
The schedule cron expression is evaluated in UTC by default unless an explicit timezone is supplied.
bq query \
--use_legacy_sql=false \
--destination_table=analytics_prod.daily_revenue_summary \
--replace=true \
--parameter=run_date:DATE:2099-03-15 \
'
SELECT region, SUM(net_revenue) AS revenue
FROM `analytics_prod.fact_orders`
WHERE order_date = @run_date
GROUP BY region
'
The --parameter flag binds a named parameter to a typed value, which works against SQL injection and lets the same query be reused across dates. Parameterized SQL is the recommended pattern for scheduled queries that depend on a run-time variable.
Cost and performance levers the exam expects you to know
Key points
The four levers that govern a BigQuery query are clustering, partitioning, materialized views, and BI Engine.
Partitioning physically splits a table into segments by ingestion time, a date or timestamp column, or an integer range. The query planner prunes partitions outside the WHERE predicate, which directly reduces bytes scanned.
Clustering further sorts the data inside each partition by up to four columns, which prunes blocks at read time when the same clustering columns appear in the predicate.
Materialized views serve repeated aggregations. BI Engine is an in-memory acceleration layer used implicitly by Looker, Looker Studio, and Connected Sheets to answer sub-second queries.
The exam frequently presents a slow dashboard scenario and asks which feature to enable. The answer is usually either a materialized view on the underlying aggregate or a BI Engine reservation in the same location as the data.
📊 Limit: A BigQuery table supports a maximum of 10,000 partitions. Partitioning by day for more than 27 years requires a different partitioning strategy or an integer-range partition.
📊 Limit: The default per-project on-demand query concurrency is 100 interactive queries. Scheduled queries also consume the daily query job quota. Heavy reporting pipelines should consider reservations.
📊 Limit: A query that exceeds six hours of execution time is terminated. A query that produces more than the configured maximum response size returns the error
Response too large to return, and the query should be rewritten to use a destination table.
Sharing query output with business consumers
BigQuery offers three primary surfaces for consumption that do not require the consumer to write SQL.
- Saved queries can be shared with named principals through the BigQuery Studio UI; the consumer opens the query and runs it as themselves.
- Connected Sheets lets a Google Sheets user point at a BigQuery table and explore it interactively with pivot tables, charts, and formulas.
- Analytics Hub publishes datasets as listings into an exchange, which lets external consumers subscribe to a curated dataset without copying it; the consumer queries the linked dataset in their own project and pays for their own bytes scanned.
Analytics Hub is the right answer when the requirement says cross-organization sharing without data duplication.
Decision Tree: Persisting BigQuery query output
💡 Exam Trap: A standard view does not store data and does not reduce query cost. Every reference to a view re-executes the underlying SQL. If the goal is to cache an expensive aggregate, the answer is a materialized view, not a view.
💡 Exam Trap:
SELECT *reads every column. Even when the WHERE clause prunes most rows, BigQuery still bills for every byte of every projected column. The exam often hides this trap in a question about reducing query cost.
💡 Exam Trap: Scheduled queries default to UTC. A schedule of
every day 02:00runs at 02:00 UTC, not in the local time of the analyst. Always set the timezone explicitly when the report must align to a business day.
⚠️ Anti-Pattern: Building reporting logic as a chain of standard views nested four or five deep. The planner expands every view on every reference, the query plan becomes opaque, and small changes to a base view ripple silently into every dashboard. Flatten the logic into a materialized view or a scheduled query that writes a destination table.
⚠️ Anti-Pattern: Granting individual users
bigquery.userat the project level so they can run scheduled queries. The least-privilege approach is a dedicated service account withbigquery.dataVieweron the source andbigquery.dataEditoron the destination, andbigquery.jobUseron the project that runs the job.
🎯 Scenario: A finance analyst built a monthly revenue dashboard that scans a 4 TB partitioned table. The dashboard takes 18 seconds to load and costs $20 per refresh. The analyst is asked to make it sub-second and one-tenth the cost. The right answer combines a materialized view that pre-aggregates revenue by month, region, and category, plus a BI Engine reservation in the dataset location. Switching to clustered columns on
regionandcategoryfurther prunes block reads when the consumer drills into a single region.
Decision Anchor: Choose a materialized view when the same aggregate is queried often and the base table changes slowly. Choose a scheduled query writing to a destination table when the transformation logic is too complex for a materialized view, when you need full control of the partitioning of the output, or when the consumer needs a static snapshot at a known time of day. ---
