Google Cloud Previews ai.classify and ai.extract SQL Functions in AlloyDB AI
Google Cloud has announced the preview of two new SQL functions, ai.classify and ai.extract, within its AlloyDB AI query engine, enabling direct in-database text classification and structured extraction to reduce latency, costs, and compliance risks associated with external model calls.
Google Cloud announced on November 12, 2026, the preview of two new SQL functions, ai.classify and ai.extract, within its AlloyDB AI query engine. These functions allow developers to perform text classification and structured data extraction directly inside the database using standard SQL, eliminating the need to export data to external model endpoints.
Historically, processing vast amounts of unstructured text stored in transactional databases—such as clinical notes, customer reviews, and support tickets—required building complex application code. Developers had to export data, call external APIs, write custom prompt wrappers, parse unpredictable responses, and manage retry logic. This application-side loop introduced query latency, bloated application code, increased model token costs, and created data compliance risks by moving sensitive information across multiple network boundaries.
The new ai.classify function supports single-label and multi-label classification, allowing users to define categories via simple label lists or 2D arrays containing descriptions, and supports few-shot prompting. The ai.extract function transforms unstructured text into machine-readable JSON data matching a specified schema, handling system instructions internally to save developers from writing prompt templates or response parsers.
To enhance performance, Google Cloud introduced 'smart batching.' When these AI functions are used in SQL WHERE clause expressions, the database engine automatically groups inputs into optimized micro-batches before sending them to Gemini Enterprise Agent Platform models. This mechanism significantly speeds up inference compared to row-at-a-time evaluations and reduces total model token spend by optimizing input prompt overhead.