Natural Language to SQL

Ask your database anything in plain English. Get precise results in seconds.

How It Works

  1. You ask a question — “Show me revenue by region for Q1 2024”
  2. Schema Understanding — The engine maps your question to relevant tables, columns, and joins using the auto-profiled catalog
  3. SQL Generation — A precise SQL query is generated, validated for safety and correctness
  4. Execution — Query runs read-only against your connected database with enforced timeouts
  5. Results — Data returned as a table, with a natural language explanation and optional chart

Capabilities

Multi-Table Joins

Automatically infers joins across related tables using foreign keys and naming conventions.

Aggregations

SUM, COUNT, AVG, MIN, MAX, GROUP BY, HAVING — with time-series bucketing.

Dialect-Aware

Generates syntax specific to your database: PostgreSQL, Snowflake, BigQuery, Oracle, SQL Server, MySQL.

Temporal Queries

Understands "last month", "Q1 2024", "year over year", "rolling 7 days".

Follow-Up Context

Remembers conversation context — "now break that down by department" works.

Query Memory

Previously asked questions resolve instantly from cache — no AI call needed.

Example Queries

Show me top 10 customers by total order value

Joins customers → orders, aggregates, sorts descending

How many invoices were flagged as duplicates this month?

Filters documents by type, status, and date range

Compare revenue Q1 2024 vs Q1 2023 by product category

Year-over-year comparison with GROUP BY

Which vendors have overdue invoices greater than $50K?

Multi-table join with date math and amount filter

What is the average processing time per invoice by department?

Timestamp difference calculation with grouping

Safety Guardrails

GuardBehavior
Read-OnlyOnly SELECT allowed. Mutations blocked at engine level.
TimeoutQueries cancelled after configurable limit (default 30s).
Row LimitResults capped at 10,000 rows (configurable).
PII MaskingColumns flagged as PII can be excluded or masked in results.
Tenant IsolationRow Level Security ensures queries only return your data.

API Usage

Programmatic access via the NL2SQL API endpoint:

POST /api/nl2sql/query
Authorization: Bearer <api-key>
Content-Type: application/json

{
  "question": "Show me revenue by month for 2024",
  "connectionId": "conn_abc123",
  "options": {
    "maxRows": 1000,
    "timeout": 15000,
    "includeSQL": true
  }
}

Response includes: sql, rows, columns, explanation, confidence.

Accuracy & Feedback

  • 95%+ accuracy on first attempt across standard analytical queries
  • Thumbs up/down — rate results to improve accuracy over time
  • SQL editing — modify generated SQL if needed, save corrections as feedback
  • Confidence scoring — low-confidence queries flagged for review before execution

Supported Dialects

PostgreSQLSnowflakeBigQueryOracleSQL ServerMySQL

Each dialect uses proper syntax, functions, and quoting conventions (e.g., ILIKE for Postgres, REGEXP_LIKE for Oracle).