BigQuery now offers AI.AGG, a preview‑only function that performs native semantic aggregation across massive datasets. By embedding a distributed map‑reduce style workflow inside the database, engineers can issue a single SQL statement that synthesizes text or multimodal data at scale, eliminating the need for custom external orchestration.
What Changed: AI.AGG Preview
The new function abstracts the complexity of chunking data to fit LLM context windows. When a query runs, the engine validates each row against a 10 MiB payload limit, groups rows into token‑safe batches, dispatches parallel inference calls to Vertex AI (using a Gemini endpoint), and then recursively merges the intermediate summaries until a single result per GROUP BY clause is produced. Unlike row‑level functions such as AI.CLASSIFY, AI.AGG relies on full‑weight models for every stage.
Why It Matters for Engineers
AI engineers, platform teams, and SREs can now replace bespoke map‑reduce pipelines with a managed SQL call. The shift reduces code maintenance, eliminates custom rate‑limiting logic, and leverages BigQuery’s native scaling. For security and DevSecOps practitioners, the data movement stays within the Google Cloud environment, simplifying audit trails compared to external services.
Architecture and Operational Implications
- Batch orchestration inside BigQuery: The engine handles row‑level validation, context‑safe batching, and recursive synthesis automatically.
- Parallel LLM inference: Each batch is sent to Vertex AI in parallel, meaning cost and latency scale with the number of batches rather than the total row count.
- Multimodal support: By using Object Tables and
OBJ.GET_ACCESS_URL, the function can ingest images or other binary assets alongside text. - Production readiness: As a preview feature, users should test performance and cost impact before full rollout, and monitor for batch‑level errors such as payloads exceeding the 10 MiB limit.
Security and Governance Considerations
Because every batch is transmitted to Vertex AI, practitioners must ensure that the service account executing the query has appropriate permissions for both BigQuery and Vertex AI. Data sent to the LLM is subject to Google’s data handling policies, so teams should review compliance requirements for any sensitive content. The recursive synthesis step means that intermediate summaries may contain partial data; logging and monitoring should capture both input batch sizes and LLM response metadata to support auditability.
Related CloudNinjas coverage: Google Cloud.
What This Means For Practitioners
Adopt AI.AGG when you need high‑level insights from millions of rows and want to avoid building external aggregation pipelines. Start with small, controlled queries to gauge token usage and cost, then scale up while monitoring batch errors and LLM latency. Evaluate the preview status against your production risk tolerance, and align IAM policies to limit LLM access to only the required service accounts. As the feature matures, expect tighter integration with cost controls and monitoring dashboards.

