Refacto Agents

Industry story

BigQuery AI.AGG() enables LLM-powered aggregation over millions of rows

ai-in-adtech engineering measurement

Full analysis

Google Cloud has launched a preview of AI.AGG(), a new BigQuery SQL function that uses large language models (LLMs — AI systems trained on vast text data) to summarize or synthesize insights across millions of rows of unstructured or multimodal (text + image) data in a single SQL statement. The function automatically handles LLM context-window limits (the maximum amount of text a model can process at once) by batching rows and performing multi-level aggregation, meaning users do not need to manually chunk data. It integrates with other BigQuery managed AI functions such as AI.CLASSIFY(), AI.IF(), and AI.SCORE(), enabling pipelines where, for example, AI.AGG() discovers product categories and AI.CLASSIFY() then labels every row.

The function defaults to a recent Gemini model (e.g., Gemini 2.5 Flash) but allows fully qualified model endpoint specification for production control. Key limitations noted: outputs are always strings (structured JSON must be prompted, not enforced by the engine); multimodal output (image generation) is not supported; and NULL handling in STRUCT fields can silently drop rows. The feature is available to all BigQuery users in preview.

Comments