Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a BigQuery Analytics Agent

Design an agent that answers analytics questions by finding the right tables, running cost-checked BigQuery jobs as the asking user, and replying with answers traced to the queries it ran.

Problem statement

For this exercise, assume a company keeps its analytics data in a BigQuery-style warehouse: it is serverless, each query is billed by the bytes it scans, queries run as asynchronous jobs, a dry run estimates a query's bytes without running it, and access is controlled per dataset, table and column.

Employees ask an internal agent questions in plain language, such as "How many daily active users did we have in Brazil last week?"

The agent looks up which datasets, tables and columns might answer the question, writes SQL, checks each query's cost with a dry run, runs read-only jobs with the asking user's own permissions, looks at the results, and may run a few more queries before it answers. Every answer shows the queries and tables it used.

When a question is unclear, the agent asks a clarifying question instead of guessing. Users can ask follow-up questions in the same conversation and can cancel a question that is still running.

Training the language model, building the warehouse, writing data pipelines, and deciding who may access which data are outside scope.

What to build

  1. A user asks a question in a conversation and gets an answer that cites the queries it ran and their results, a clarifying question, or a clear refusal.
  2. The agent finds candidate datasets, tables and columns, with their descriptions, using only metadata the asking user is allowed to see.
  3. The agent runs only read-only queries as the asking user, and a dry run checks each one against per-query and per-question scanned-bytes budgets before it starts.
  4. A user can ask follow-up questions that reuse the conversation's context, see the SQL behind any number, and cancel a question that is still running.

At scale

  • For this exercise, assume up to 150 questions in progress at peak, over a warehouse of 40,000 tables; the largest tables hold tens of terabytes and are partitioned by date.
  • For this exercise, assume the agent shows first progress within 3 seconds and finishes 90 percent of questions within 60 seconds, while a question may keep running for up to 10 minutes.
  • For this exercise, assume each question may run at most 8 queries and scan at most 100 GB in total, each query may scan at most 25 GB unless the user approves a larger scan, an approval never takes a question past 100 GB or the daily cap, and the company caps the agent's total scanned bytes per day.
  • For this exercise, assume conversations, plans, queries and result references are kept for 90 days for audit and debugging.