Databricks AI_MASK v2 can finish a SQL query without masking every row
The beta switches from a string to a structured result. Pipelines that redact support tickets or agent traces need to check the error field before handing text downstream.
Databricks announced a beta version of ai_mask on November 23. The SQL function can redact sensitive values in free text such as support tickets and agent traces. The important change for a batch pipeline: a successful query no longer means every row was processed successfully. In v2, an individual detection call can fail while the query keeps going.
The version switch changes what SQL returns
Version 1.0 remains the default. It takes free-text labels, replaces detected values with [MASKED], and returns a STRING. Version 2.0 requires options => map('version', '2.0'). It uses a Databricks-built detection model and accepts 90 system-defined classifiers. Passing no list or NULL selects an 18-classifier default set, not all 90. Version 2.0 replaces detected values with typed placeholders such as [EMAIL_ADDRESS] and returns a VARIANT containing response, metadata.version, and error_message.
A missing response is not a clean bill of health
The function reference distinguishes a bad configuration from a failed detection. An unknown classifier or an explicitly empty classifier array fails the query. A timeout after retries can instead leave just one row with a null response and a populated error_message. Null input returns SQL NULL; empty input returns a result with a null response. A null response on its own therefore does not tell you what happened.
For a pipeline feeding an analytics agent, test those cases separately. Keep a count of row failures, exclude failed rows from the agent-facing output, and do not fall back to the original text when response is null. Use synthetic fixtures to check that the classifier set covers the fields you intend to redact; the vendor’s examples note that model results can vary.
Check deployment eligibility before adopting the new return type. The reference says v2 is unavailable on workspaces with the compliance security profile and points those users to v1. Some listed regions require cross-Geo processing for v2. Verify both the workspace and region before making a v2 query part of a shared redaction workflow.
sources
- Databricks November 2026 release notes: AI_MASK v2docs.databricks.com
- Databricks SQL reference: ai_mask functiondocs.databricks.com
- Databricks feature region supportdocs.databricks.com
comments · 0