BigQuery Interview Questions: Partitioning, Clustering and Cost

A practical walkthrough of BigQuery interview questions: pick a partition key and cluster order for a 2 TB events table, estimate bytes scanned, and give a 60-second answer.

By AI Interview AssistantPublished 9 min read

A candidate sketches a table layout and calculation diagrams in a notebook beside a laptop while preparing for an interview.

Expect questions that hand you a concrete table and ask you to choose a partition key, a clustering order and a cost guardrail, then defend the trade-off. Answer by naming the query pattern first, stating the partition and cluster choice with the reason, and quantifying the bytes scanned before and after. Interviewers want your reasoning about cost and pruning, not a feature list. The bigquery interview questions below all follow that shape, and one worked table carries most of them.

What a BigQuery question is really asking

The interviewer is testing whether you connect a query pattern to storage layout and cost. Syntax you can look up; a decision about how a table should be laid out, and what it saves, is what separates a candidate who has run queries from one who has owned a table.

Every answer has three layers, in this order:

  1. What the data looks like. Row count, columns, how often it is written, whether rows are updated.
  2. How it will be queried. Which columns appear in filters, and whether those filters are ranges, equality or both.
  3. What that costs. Bytes scanned per query, and what it becomes after pruning.

"It depends" fails because it stops at layer two. "It depends on the filter column, so I would partition on event_date and keep the id in clustering" passes, because it names the dependency and commits to a choice you can then defend.

Partitioning: choose the key from the WHERE clause

The rule: partition on the column that appears as a range or equality filter in most queries, which is usually a date. Partitioning splits the table into separate storage blocks, and a filter on the partition column lets the engine skip the blocks that cannot match.

An engineer points to color-coded data partitions on a whiteboard while a colleague listens in a sunlit office.

Work through a scenario with every assumption labelled:

Assume the events table is 2 TB.
Assume it is partitioned daily by event_date.
Assume the table holds 365 days of data.
Assume 90% of queries filter a 7-day window.

Bytes scanned without partitioning:
  2 TB per query.

Bytes scanned with daily partitioning, 7-day window:
  2 TB x 7 / 365 = 2 TB x 0.0192 = about 0.038 TB, roughly 38 GB.

Same query without partitioning: 2 TB.

The saving comes from the partition filter, not from the query being clever. State the assumptions out loud as you write them, because the interviewer may change one: if the table held 90 days instead of 365, the same 7-day window would read 2 TB x 7 / 90, about 155 GB, and the argument for partitioning gets stronger, not weaker.

The common mistake is partitioning on a high-cardinality id column, such as customer_id. That creates millions of tiny partitions, each with overhead, and pruning does not help because most queries filter a date range, not a single customer. Keep partitions coarse and put the id in clustering instead.

Expect the follow-up: what happens to partition pruning when the filter wraps the column in a function? If you write a condition that applies a function to event_date, the engine cannot compare it to the partition boundaries, so it scans every partition. Filter on the raw column with a plain range instead.

Clustering: order the columns after the partition

Clustering sorts rows within each partition by the clustered columns, in the order you declare them. Equality and prefix filters on those columns let the engine skip blocks inside a partition.

Take the same events table and cluster on customer_id, then event_type. A query that filters both columns reads only the blocks matching that customer and that event type. A query that filters customer_id alone still benefits, because customer_id is the first clustered column. A query that filters event_type alone prunes much less: the engine cannot use the second column efficiently without a value for the first, so it reads every customer's blocks within the matching partitions. That is why the order matters, and why you should say which filters are most common before you name the order.

The mistake is clustering on five columns "just in case". Each extra column adds write overhead and gives diminishing returns, and a long cluster list usually means the candidate has not decided what the queries actually filter. Two or three columns, matching the filter order, is a defensible choice you can explain.

Cost control: say the bytes-scanned number

Estimate bytes scanned as table size times the fraction of partitions and blocks the query reads. Then name the guardrails:

  • Partition filters on every query, so the engine can prune before reading.
  • Select only the columns you need, since reading fewer columns reads fewer blocks.
  • Dry runs before running an expensive query, to see the estimate first.
  • Byte limits at the table or query level, so a runaway query fails instead of billing.

The mistake to avoid is answering "use LIMIT to reduce cost". LIMIT caps the rows returned, not the bytes read: the engine still scans the matching partitions and blocks to find those rows. If you catch yourself about to say it, replace it with the partition-filter answer.

A 60-second sample answer, start to finish

Here is an illustrative answer for the events table, spoken as one piece. It is an example, not a transcript of a real interview.

"The table is 2 TB of events, partitioned daily by event_date, and most queries filter a 7-day window. I would keep that partition, because a 7-day filter reads about 2 TB times 7 over 365, roughly 38 GB instead of 2 TB. For clustering I would put customer_id first and event_type second, since customer queries usually filter a customer and sometimes an event type, and that order lets a customer-only filter still prune. The option I would reject is no partitioning with a cluster on event_date: clustering helps only within blocks, so a 7-day query would still scan the whole 2 TB, and the cost difference is the reason I would not do it. The main risk is a query that wraps event_date in a function, which kills pruning, so I would keep date filters on the raw column. Want me to walk through how I would check the estimate?"

That closing sentence invites the follow-up instead of ending flat. It also shows you know the estimate has assumptions worth checking.

SQL follow-ups that test the same reasoning

A short query follow-up usually asks you to deduplicate to the latest row per customer_id. A window function does it:

SELECT customer_id, event_type, event_date
FROM (
  SELECT
    customer_id,
    event_type,
    event_date,
    ROW_NUMBER() OVER (
      PARTITION BY customer_id
      ORDER BY event_date DESC
    ) AS rn
  FROM events
  WHERE event_date BETWEEN '2024-01-01' AND '2024-01-07'
)
WHERE rn = 1;

Trace it on a small input: two rows for customer 7, dated 3 January and 5 January. The window numbers the 5 January row 1 and the 3 January row 2, and the outer filter keeps the 5 January row. The date filter in the subquery is what lets the partition prune; the window's PARTITION BY customer_id is a separate thing and does not use the table's clustering directly, but sorting by customer_id keeps the shuffle closer to the clustered order.

The cost narration that should accompany it: name the partitions the date filter reads, say the window sorts within those partitions, and give the estimate before you run it. Writing correct SQL but never mentioning scan size is the mistake here; the fix is to narrate the cost before the query runs, not after.

If the interviewer then asks you to predict which partitions and blocks a query with both a date filter and a customer filter reads, answer in the same order: the date filter selects partitions, the customer filter selects blocks within them, and the total is the product of the two fractions, stated with your assumptions.

The one rule to carry into the room

Every BigQuery answer names the query pattern, the layout choice and the cost consequence, in that order. If you remember only one sentence, make it the bytes-scanned estimate with its assumptions stated, because it turns an opinion into an argument the interviewer can test. Practise saying the estimate and the rejected option in one breath; that is the shape the harder bigquery interview questions reward. For the general framing behind these answers, see data engineering trade-off answers and cloud architecture trade-off reasoning, and for delivery, answering technical questions out loud.

Frequently asked questions

Should I mention BigQuery pricing models in the interview?

Mention them only to support a layout decision. Say that on-demand pricing bills by bytes scanned, so pruning directly reduces cost, and that flat-rate commitments change who pays but not how many bytes a badly filtered query reads. If you are unsure which model the team uses, ask; the partition and cluster reasoning stands either way.

What if the interviewer asks about partitioning a table that is updated in place?

Say that updates and deletes interact with partitioning and clustering, and that you would check how the team handles them before choosing a layout. If rows change after they land, a partition key that moves with the row can cause rewrites; a stable date column is safer. Then return to the query pattern, which still decides the key.

How do I answer if I have only used BigQuery through a BI tool?

Say so plainly, then reason from the query pattern anyway. You can still name the filter column, propose a partition key and estimate the fraction of the table a 7-day window reads. Interviewers accept limited hands-on exposure when the reasoning is sound; claiming experience you do not have is the risk.

Is it worth memorising BigQuery SQL syntax for the interview?

Learn the shapes you will write, such as a window function for deduplication and a date range filter, but do not memorise function signatures. Interviewers usually care more about whether you can explain the scan cost and the pruning than whether you recall exact syntax, and they will often let you describe a query in words.

Preparing data interview answers? See how AI Interview assistant works.

  • Bigquery interview questions
  • Data engineering interview
  • Sql interview
  • Cloud data warehouse interview
  • Technical interview preparation
A wall of pigeonhole shelves sorted into separate sections by wooden dividers, with a hand placing a folder into one section

12 min read

Data Partitioning System Design Interview: Choosing a Key

A spoken structure for choosing a partition key in interviews: start from the access pattern, name the trade-off you accept, and handle the follow-up questions.

  • Data partitioning system design interview
  • Data partitioning interview explanation
Clear industrial pipes and valves feeding a glowing reservoir inside a clean facility

12 min read

Data Engineering Interview Questions: Trade-Off Answers

Answer data engineering interview questions by naming the concept, the decision, the trade-off and one honest example, so you can defend your choices when pushed.

  • Data engineering interview questions
  • Data engineering interview answers
A C++ developer at a dual-monitor desk comparing two code approaches side by side while weighing a trade-off, with a pros and cons list on a notepad

11 min read

C++ Interview Questions: Define, Cost, Example

Most C++ interview questions are trade-off questions in disguise. Learn a three-move answer — define, name the cost, give an example — and handle the follow-up without freezing.

  • C interview questions
  • C interview answers