Turn unstructured data into structured SQL insights with BigQuery AI.AGG (now GA) Google Cloud's BigQuery AI.AGG() function reached general availability, adding a custom output_schema parameter that formats Gemini model responses into structured fields such as text, numbers, booleans and lists instead of free-form paragraph summaries. The function lets data teams synthesize thousands to millions of rows of unstructured text and multimodal data per group directly in SQL, and Google said the structured output supports workflows including automated bug and ticket deduplication, dashboard-ready feedback analysis, AI agent and chatbot quality monitoring, log triage and e-commerce catalog analysis. Google paired the GA release with BigQuery's new token-based cost management controls for building predictable production semantic aggregation pipelines. Since we first introduced AI.AGG in Preview https://cloud.google.com/blog/products/data-analytics/deep-dive-into-bigquery-ai-agg-function , data teams have used it to synthesize millions of rows of unstructured text and multimodal data directly in SQL, from distilling product feedback to investigating application logs. The function https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-agg in BigQuery recently reached general availability GA . Alongside the GA release, we also rolled out one of the most requested capabilities from our preview users: custom structured output support . Combined with BigQuery's new token-based cost management controls https://cloud.google.com/blog/products/data-analytics/using-bigquerys-generative-ai-cost-management-features , you can now build predictable, production-ready semantic aggregation pipelines straight from SQL. Using Gemini models, AI.AGG brings SQL aggregation to unstructured text and multimodal data. You can pass natural language instructions to AI.AGG to synthesize thousands or even millions of rows per group, all without writing custom application pipelines or hitting model context window limits. If you want a closer look at how BigQuery handles multi-level aggregation across massive datasets under the hood, read our deep dive into the BigQuery AI.AGG function https://cloud.google.com/blog/products/data-analytics/deep-dive-into-bigquery-ai-agg-function . During Preview, AI.AGG returned a paragraph summary for each group. This works well when a human analyst is reading query results in the console. However, teams building automated data pipelines, downstream SQL joins, or business intelligence dashboards need structured fields that they can filter, unnest, and chart. The new output schema parameter solves this directly. Instead of returning a block of free-form text, BigQuery automatically formats the model's response to match the exact structure you define, returning neatly organized fields like text, numbers, booleans, or lists that are ready to query right away. AI.AGG and structured output Getting structured results directly from AI.AGG unlocks new workflows for analytics and engineering teams: Automated bug and ticket deduplication: Group thousands of incoming bug reports or support tickets to automatically identify duplicate clusters, severity levels, and issue counts, a pattern already used internally at Google. Dashboard-ready feedback analysis: Aggregate written customer reviews, voice survey recordings, or support call audio by product category to extract top recurring themes, mention counts, and standardized sentiment labels that feed straight into dashboards. AI agent and chatbot quality monitoring: Analyze thousands of customer support chat transcripts to extract top failure scenarios, resolution rates, and suggested prompt or knowledge-base fixes. Application log and incident triage: Summarize bursts of error logs by service or time window into structured root-cause hypotheses, affected components, and recommended next steps for on-call engineers. E-commerce catalog and multimodal analysis: Group product images and descriptions by brand or category to extract common visual attributes, missing metadata tags, or quality issues across your inventory. Let's look at how the output schema parameter works in practice. In our previous deep dive blog https://cloud.google.com/blog/products/data-analytics/deep-dive-into-bigquery-ai-agg-function , we used AI.AGG to analyze unstructured Apache Spark INFO logs grouped by Component , which returned a free-form text summary of each component's behavior and anomalies. By adding output schema to that same query, we can turn those free-form summaries into structured data ready for downstream dashboards or alerting. Here, output schema instructs AI.AGG to return a description of the component's normal operation alongside an issues array, capturing a concise summary of each detected problem issue desc and how many times it occurred occurrences : You can see how the results are now neatly organized into nested STRUCT and ARRAY columns, allowing a single component like python.PythonRunner to list multiple distinct issues with their exact occurrence counts: As you design queries with AI.AGG and output schema , keep these four best practices in mind: Mark required fields so nothing is left blank: Include NOT NULL on fields in your output schema unless missing values are acceptable. This makes sure the model always fills in every field, preventing unexpected NULL s in your downstream queries or dashboards. Include a quick example in your prompt: Giving the model a short example of what a good answer looks like for instance, "issues": {"issue desc": "Stage 24 shows a significant backlog of tasks due to high CPU usage", "occurrences": 164} in the query above helps guide the level of detail and tone of the results. Keep field formatting rules in the schema description: Instead of crowding your main prompt with formatting instructions for individual columns, attach OPTIONS description = '...' directly to each field in your output schema . This keeps your main prompt focused on the big-picture question while clearly telling the model what values or format you expect for each field. Set a limit when asking for lists: AI.AGG caps each group's response at 10,000 tokens. When returning a list, ask for a specific number of items in your prompt, such as "Summarize the top 3 recurring themes" or "List the top 5 root causes," so the response stays concise and never hits the token limit. With AI.AGG now in GA, new support for structured outputs, and token-based quotas for cost management, you have everything you need to run AI-powered aggregations reliably in production. To start building with AI.AGG , check out these resources: Explore the syntax and examples in the official documentation for AI.AGG https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-agg . Read the deep dive into the BigQuery AI.AGG function https://cloud.google.com/blog/products/data-analytics/deep-dive-into-bigquery-ai-agg-function for architectural background and multi-level aggregation details. Learn how to set project-level and user-level token guardrails in Using BigQuery's generative AI cost management features https://cloud.google.com/blog/products/data-analytics/using-bigquerys-generative-ai-cost-management-features .