llm_filter function evaluates a condition based on a given prompt and returns a boolean value (TRUE or FALSE). This function mostly used in the workload of WHERE clause of a query.
Modalities
Text
Filter rows using tabular string columns incontext_columns.
Image
Usetype: 'image' with a vision-capable model to filter on visual criteria.
Voice
Filter on spoken content withtype: 'audio' and transcription_model (OpenAI / Azure).
1. Simple Usage (without data)
1.1 Using an Inline Prompt
gpt-4 model. If the model returns TRUE, the row is included in the result.
1.2 Using a Named Prompt
eco-friendly-check) is used to determine if the product description is eco-friendly. This allows for reusing pre-configured prompts for similar filtering tasks.
1.3 Combining with Other SQL Logic
llm_filter with other SQL logic. It filters the products based on the eco-friendliness of their descriptions and processes the result in a subquery for further use.
1.4 Actual Usage (with data)
llm_filter to filter reviews based on positive sentiment. It then further filters the results to only include reviews with content longer than 50 characters.
2. Input Parameters
Thellm_filter function accepts three structured inputs: model configuration, prompt configuration, and input data columns.
2.1 Model Configuration
- Parameter:
model_nameandsecret_name
2.1.1 Model Selection
- Description: Specifies the model used for text generation.
- Example:
2.1.2 Model Selection with Secret
- Description: Specifies the model along with the secret name to be used for authentication when accessing the model.
- Example:
2.2 Prompt Configuration
-
Parameter:
promptorprompt_namewithcontext_columns2.2.1 Inline Prompt
Directly provides the prompt with context columns.- Example:
2.2.2 Named Prompt
References a pre-configured prompt with context columns.- Example:
2.2.3 Named Prompt with Version
References a specific version of a prompt with context columns.- Example:
- Example:
2.3 Context Columns Configuration
- Parameter:
context_columnsarray - Description: Specifies the columns from the table to be passed to the model as input. Each column can have three properties:
data: The SQL column data (required)name: Custom name for the column to be referenced in the prompt (optional)type: Data type —"tabular"(default),"image", or"audio"(audio requirestranscription_model)
- Example:
3. Output
The function returns a BOOLEAN value (TRUE or FALSE), indicating whether the row satisfies the condition specified in the prompt.
Example Output:For a prompt like “Is this product description eco-friendly?”:
- Input Row:
product_description: “Made from 100% recyclable materials, this product is perfect for eco-conscious buyers.”
- Output:
TRUE

