Create Validated Queries
There are two primary ways to add queries to your knowledge base: directly from the chat interface or in bulk using a CSV file.Create from the Chat Interface
The most common workflow is to validate queries as you interact with the system. This allows you to refine the AI’s generated SQL or provide your own from scratch. An easy workflow to define validated queries is to ask the question in the chat, provide feedback or edit the generated SQL, and then validate the response.- Ask a question and review the generated answer.
- If the answer is correct, click the thumb up icon.
- In the Review a Question modal that appears, confirm or edit the natural language question that the SQL code answers.
- After confirmation, the query will be saved and listed in the Knowledge > Reviewed Queries tab.

- If the answer needs changes, click the Edit button (pencil icon) to modify the SQL. Once you are satisfied, click Mark as reviewed.
Example: Editing a Query for Granularity
This example shows how to refine a query to get a more detailed view of your data. Suppose you ask, “Show me the yearly ARR trend,” and the system generates the following correct, but high-level, query:
DATE_TRUNC
function from YEAR
to QUARTER
.
Here is the edited SQL:


Bulk Upload with CSV
For adding many validated queries at once, you can use the CSV upload option in the Knowledge > Reviewed Queries tab. This is ideal for migrating existing reports or defining a set of canonical metrics from the start. To bulk upload, create a CSV file that contains two column headers:Query
and SQL
. Populate the rows with the natural language questions and their corresponding SQL code.

Best Practices for Well-Formed SQL
For a validated query to be effective and reusable, follow these best practices when writing your SQL:- Keep it concise and readable: Write SQL that is easy to understand. If the logic is complex, use comments or break it down.
- Split complex examples: Instead of creating one example that calculates multiple metrics (e.g., “Show revenue and ARR trend”), split it into two separate, focused examples (“Show revenue trend” and “Show ARR trend”).
- Use CTEs for complex logic: If the SQL requires multiple steps or transformations, break it down into more understandable Common Table Expressions (CTEs).
- Be consistent: Use a consistent SQL structure for different variations of the same metric. For example, the queries for “Yearly trend of ARR” and “ARR by segment” should be built from a consistent base calculation of ARR, ideally using the same CTE.
Combining with Language Context for Complex Cases
While Validated Queries are powerful, some complex business rules are best enforced by pairing them with explicit instructions in your Language Context. Validated Queries teach the model how to calculate a specific metric, while Language Context can teach it what not to do to avoid common logical errors. For instance, imagine you have astatewise_population
table with a pre-aggregated country_population
column. Summing this column across multiple states from the same country would lead to massive double-counting.
While a Validated Query can show the correct way to get the population, adding a clear instruction in Language Context provides an extra layer of protection against mistakes:
Instruction Example: “Never sum up the country_population
column across different rows for the same country.”
Using both features together ensures that even when the AI generates new or slightly different queries, it still adheres to your most important business logic.