For more than a decade, BigQuery has helped set standards for structured data aggregation, calculating financial sums, counting active users, and computing historical averages at a petabyte scale in seconds. But as modern enterprises become inundated with unstructured data — application logs, customer service transcripts, product imagery, and diagnostic reports — a critical gap has emerged. Historically, relational SQL engines have lacked the native ability to aggregate, synthesize, and extract overarching semantic themes from millions of rows of text and multimodal data.
While BigQuery recently introduced powerful row-level AI functions (like AI. CLASSIFY), analyzing massive datasets holistically presents a unique architectural challenge: the large language model (LLM) context window. Even with advanced foundation models like Gemini, you cannot pass millions of rows into a single prompt without triggering severe truncation or hard execution failures. Traditionally, solving this required data engineering teams to construct complex external map-reduce pipelines, manage rate-limiting backoffs, and recursively stitch chunked summaries together.
Today, we are thrilled to deep-dive into AI. AGG — currently in preview — a fully managed, multi-level semantic aggregation function natively embedded within BigQuery GoogleSQL. By conceptualizing semantic aggregation as a distributed map-reduce problem, AI. AGG enables data teams to run natural-language instructions over millions of rows of data using a single SQL query. Here is a look under the hood at how it works, transformative enterprise use cases, and best practices for deploying it in production. Turning petabytes of data into semantic insights natively in BigQuery.
AGG abstracts the immense engineering complexity of chunking and parallel execution. AGG query, the BigQuery engine automatically orchestrates a sequence natively within the database: Row-level validation: The engine helps verify no single row exceeds the maximum context window (dropping or returning an error on payloads >10 MiB). Context-safe batching: The engine dynamically groups input rows into smaller batches that safely fit within the token limits of your chosen Gemini endpoint. Parallel inference: Your natural-language SQL prompt is applied to each batch in parallel, generating intermediate semantic summar
