Generating SQL in Validators and Filters
Learn how to use AI language models to enable text-to-SQL functionality when composing queries for SQL validators and filters
When configuring Custom SQL validators and SQL filters, you can use external Large Language Model (LLM) providers like Anthropic Claude to compose and correct your SQL queries.
Instead of writing complex SQL queries from scratch, you can leverage LLM credentials in Validio to:
- Generate SQL automatically from natural language descriptions of what you need to validate in your data
- Quickly fix broken SQL when the query test returns errors and fails
This feature is particularly valuable when working with complex data validation scenarios where manual SQL writing would be time-consuming or error-prone.
Prerequisites
This feature requires that you have:
- Enabled the AI Feature > Allow LLM Credentials setting in your Validio Workspace. See Configuring Global Settings.
- Configured at least one LLM credential, such as Anthropic, in your namespace. Each credential is connected to one model. See LLM Credentials.
Generating SQL in Custom Validators
LLM credentials simplifies the configuration of custom SQL validators. Instead of writing the SQL query for the metric calculation from scratch, use the Generate SQL button to describe the metric you want to calculate and let the AI model generate the SQL query for you.

Selecting the LLM credential with the model to generate the query

Generated SQL query with options to accept or reject (or test again)
After defining the metric calculation, you can continue configuring the Custom SQL validator. See Custom SQL Validators.
Fixing Errors in SQL Queries
If testing your custom SQL query returns errors, you can use Fix errors and select an LLM credential to analyze and correct the errors for you.

Selecting the LLM Credential to fix query errors
Fixing the query may take a few minutes depending on the complexity of the query. After the query is corrected, you can run another test. The changes will not be saved until you click accept. See Custom SQL Validators.
Generating SQL in Filters
The LLM credential can also assist with writing a SQL filter query. In the SQL filter configuration, use Generate SQL to describe your filtering requirements, and select the LLM credential to generate the SQL query.

Selecting an LLM credential to generate the SQL query for your filtering requirements

Previewing the generated filter and results
After you accept the SQL query, you can create the SQL filter. For more examples, see SQL Filter.
Updated 1 day ago