ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
NewsMaterial2 min readDisconfirmAI Editorial

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.

2026-11-12

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.

Sign in / Sign up
ReadingResearchRadarInvestment framework

These features are currently in preview and require the google_ml_integration extension (version 1.6.1 or later) on PostgreSQL 18, with the enable_preview_ai_functions parameter set to TRUE. Google Cloud plans to further expand in-database AI capabilities with upcoming enhancements for advanced cost optimization, line-level provenance tracking, and query pushdowns beyond WHERE clauses.

Sources

  • cloud.google.comGoogle Cloud Blog↗
Continue researching →