What changed
Google Cloud announced the preview of two new SQL functions in AlloyDB AI — ai.classify and ai.extract — which allow users to perform text classification and structured data extraction directly within the database using standard SQL. These functions are available in the google_ml_integration extension (version 1.6.1 or later) on PostgreSQL 18. The functions are supported by smart batching for AI functions, which optimizes performance and reduces model token costs.
What this means in practice
The ai.classify function categorizes text into user-defined classes without requiring manual prompt engineering. Users can specify categories as a list of labels or provide descriptions for each label. It supports single-label and multi-label classification, as well as few-shot prompting and flexible execution modes for rows, arrays, and cursors. The ai.extract function transforms unstructured text into structured JSON data based on a specified schema, handling system instructions internally to avoid the need for custom prompt templates or response parsers.
The new functions are designed to streamline workflows in industries such as healthcare, financial services, legal technology, and real estate. For example, in healthcare, they can securely convert free-text clinical notes into structured records, keeping patient data within the database. In financial services, they can extract vendor details, invoice dates, and line-item totals from scanned documents.
Limitations and availability
The functions are currently in preview and require the google_ml_integration extension (version 1.6.1 or later) on PostgreSQL 18. They are available in AlloyDB AI and leverage the Gemini Enterprise Agent Platform models. Smart batching is used to group inputs into micro-batches for optimized performance, reducing inference time and model token costs. The functions are not yet generally available and are part of an ongoing expansion of in-database AI capabilities in AlloyDB.
