Prepare data for Ask AI
Use clear table and column names, then review the generated query.
Ask AI uses table definitions to turn a question into a query you can review.
- Use clear field namesMake units such as cents or milliseconds explicit.
- Select the relevant tablesKeep the question within the intended data scope.
- Ask for a specific resultName the filters, totals or ordering you need.
- Check the executed interpretationVerify field choices and returned values.
Prepare your table
- Register the table and its columns.
- Use names that explain the value:
amount_centsis clearer thanamt. - Choose the tables the question should use.
- Check that Ask AI is enabled for your instance and configured provider.
| Instead of | Prefer | Why |
|---|---|---|
amt | amount_cents | Includes the unit. |
ts | placed_ms | Says what happened and how the time is stored. |
state | order_status | Makes the meaning less ambiguous. |
No special natural-language block is needed in the schema. Do not assume the service can infer undeclared fields or your business rules.
Example table definition
# NL has no schema knobs of its own. What it needs is that the tables you
# want it to reason about are REGISTERED - the compiler is given the column
# names and types of your schemas as its entire context, so a column that
# is not declared is a column it cannot use.
namespace = "shop"
table = "orders"
primary_key = ["id"]
[[columns]]
name = "id"
ty = "str"
required = true
[[columns]]
name = "customer"
ty = "str"
[[columns]]
name = "amount_cents"
ty = "i64"
[[columns]]
name = "status"
ty = "str"
[[columns]]
name = "notes"
ty = "str"
[[columns]]
name = "placed_ms"
ty = "u64"
# Not required by NL, but the compiled plan will use it like any other
# query would - so an indexed filter column makes the answer faster.
[[indexes]]
name = "by_status"
columns = ["status"]Check the answer before using it
- Read the generated plan: does it use the intended table, fields and filters?
- Compare the returned rows with a small result you can verify yourself.
- Make the question more specific if the result is unclear.
- Use reviewed, parameterized SQL for a query your application will run repeatedly.
Ask AI availability and limits depend on the instance configuration. A generated query is a proposal to inspect, not proof that the business question was understood.