AI Agent News/stories/alloydb-ai-adds-ai-classify-and-ai-extract-sql-functions-in-preview.md

Infrastructure

AlloyDB AI adds ai.classify and ai.extract SQL functions in preview

Google Cloud has previewed two SQL functions, ai.classify and ai.extract, in AlloyDB AI. They let developers classify text and extract structured JSON inside the database using standard SQL instead of application code.

Source: cloud.google.com/blog/products/databases/ai-classify-and-ai-extract-functions-in-alloydb-ai

The functions are available in the google_ml_integration extension, version 1.6.1 or later, on PostgreSQL 18. Google Cloud says they replace a workflow that required exporting data, calling external model endpoints and parsing responses, which it argues adds latency and moves sensitive data across network boundaries.

ai.classify assigns text to user-defined categories, with single-label and multi-label output modes, optional category descriptions and inline few-shot examples. ai.extract converts free text into JSON that matches either a JSON schema or a plain list of fields. Both functions accept single values, arrays or cursors.

When the functions are used in WHERE clause expressions, AlloyDB groups inputs into micro-batches before sending them to Gemini models, which the company says speeds up query execution and reduces token spend. Google Cloud also plans further work on cost optimization, line-level provenance tracking and query pushdowns beyond WHERE clauses.

Why it matters if you build agents

Agent builders can run classification and extraction over stored text in SQL, without writing prompt templates, retry logic or response parsers in application code. Pipelines that currently send records to external model endpoints may be simplified, though the features are in preview and need a configuration flag enabled. Confirm the google_ml_integration version and PostgreSQL 18 requirement before planning production use.

Get stories like this every weekday

One short email with the day's agent tooling news.

Subscribe