Skip to content
AI.info

The Pulse

Google previews AlloyDB functions for classifying and extracting text

Google has detailed two preview SQL functions that classify text and extract structured data in AlloyDB. The functions require PostgreSQL 18 or later and version 1.6.1 or later of the google_ml_integration extension.

Google previews AlloyDB functions for classifying and extracting text

AlloyDB users can preview SQL functions that classify unstructured text and extract fields into JSON without building separate extraction pipelines. Google described the functions, ai.classify and ai.extract, in a blog post.

The functions require PostgreSQL 18 or later and version 1.6.1 or later of the google_ml_integration extension, with preview functionality enabled. AlloyDB release notes listed the functions as available in preview on October 27.

Labels and structured fields

The classification function assigns text to categories defined by the user. Developers can supply labels alone or add descriptions that give the model context for each category.

The function supports both a single-label mode, which returns the best matching category, and a multi-label mode, which returns all matching categories. It also accepts inline examples to guide classification.

The company illustrated the function with a query that sorts customer reviews by sentiment. The expected output labels a favorable review positive and two critical reviews negative. The classification documentation lists gemini-3.5-flash-lite as the default model and allows users to specify a supported pre-registered or registered custom model.

The extraction function converts unstructured text into JSON matching a target schema. Users can specify that schema as JSON or as a text list of fields. Google's example uses a free-form clinical note to extract a patient's name, age, symptoms and prescribed medications into a structured result.

The function handles system instructions internally, rather than requiring users to write prompt templates or response parsers. Other applications listed in the post include extracting vendor details and invoice totals from scanned document text, or property types and price ranges from listing descriptions.

Batch processing

Both functions support processing individual rows, arrays and cursors. For cursor-based extraction, the documentation describes streaming data through the model in manageable batches without loading the entire dataset into memory at once.

AlloyDB also offers smart batching for AI functions, previously called AI Function Acceleration. When the functions are used in SQL WHERE clause expressions, the database engine groups inputs into micro-batches before sending them to Gemini Enterprise Agent Platform models.

Google says batching speeds inference compared with evaluating rows individually and reduces model token spending by optimizing prompt overhead. Its documentation says the AI function acceleration flag must be enabled for smart batching of scalar extraction calls across multiple rows.

Preview requirements

The extraction documentation says the AI query engine and preview-function flags are off by default and can be enabled for a session without restarting the database.

Google also plans enhancements for cost optimization, line-level provenance tracking and query pushdowns beyond WHERE clauses.

Sources

Companies in this story

Related stories

Explore

More articles