Dataset
SQL query log and business question datasets for AI training
A SQL query dataset is a set of queries analysts actually ran against a company data warehouse, each kept with the schema it ran on, its execution status and runtime, and the business question that prompted it, taken from a ticket, a chat message or a saved report's description. SourceX sources these to a buyer's spec from established businesses whose data teams work in Snowflake, BigQuery, Redshift or Databricks and in tools such as Mode, Hex, Metabase and Looker. Each dataset is de-identified and licensed for an agreed permitted use.
Dataset manifest
Sourced to your spec- What it is
- Analyst-run warehouse queries in session order, each with schema, run outcome and the paired business question
- Typical systems
- Query history in Snowflake, BigQuery, Redshift and Databricks; Mode, Hex, Metabase and Looker; request tickets and chat
- Typical history
- Bounded by the warehouse's query-history retention unless the partner archived it; confirm the earliest date
- Modality
- SQL text with structured execution metadata; questions and request threads as text
- Delivery formats
- JSONL query records grouped by session, schema snapshots as DDL or JSON, request threads as text
- Preparation
- Literals in query text masked; result sets excluded or de-identified; user names replaced with roles
- Licensing
- Scoped per warehouse, team or period; permitted use agreed per license, including table and column names
- Availability
- Sourced to your spec; the paired share depends on how the partner's team logged requests and is not guaranteed
What a delivery contains
Fields vary by source system and are fixed per order. A typical delivery includes:
| Field | Type | What it holds |
|---|---|---|
| query_id | string | Pseudonymous ID for one submitted statement, stable across the session and pairing records. |
| session | object | Warehouse session or editor worksheet, the statement's position in it and the gap since the previous statement. |
| dialect | enum | Snowflake, BigQuery, Redshift, Databricks SQL or another engine, since functions and quoting differ between them. |
| sql_text | string | The statement as submitted, comments kept, with literal values replaced by typed placeholders. |
| question | object | The request in the asker's own words, with its source (ticket, chat thread, report description), asker role and timestamp. |
| pairing | object | How question and query were joined: an explicit link, pasted SQL, a shared report, or inference from analyst and time, with confidence. |
| schema_snapshot | object | Tables, columns, types and comments visible to the query's role, dated as near the run as the partner's records allow. |
| tables_referenced | array | Tables and columns the statement read, parsed from the text or taken from the warehouse's access record. |
| execution | object | Status, start time, elapsed time and bytes scanned, with the engine's error code and message for failed statements. |
| origin | object | Client that issued the statement (SQL editor, notebook, BI tool, scheduled job) and whether a person wrote it, with the basis. |
| revision_of | object | The earlier statement this one edits and the kind of change: fixed error, changed join, added filter or changed grain. |
| session_outcome | object | Which statement was accepted and the evidence: saved as a report, scheduled, sent to the requester, or abandoned. |
| result_shape | object | Column names and types of the result and its row count, with no result values. |
| masking | object | Counts of literals masked by type, and whether the masked statement still parses in its dialect. |
Field names from the table above; values are masked placeholders.
Example record
{
"query_id": "q_58b20c",
"session": { "id": "ses_91f3", "position": 4, "of": 6, "seconds_since_previous": 172 },
"dialect": "snowflake",
"sql_text": "select r.region_name, count(distinct s.account_id) as churned\nfrom analytics.fct_subscriptions s\njoin analytics.dim_accounts a on a.account_id = s.account_id\njoin analytics.dim_regions r on r.region_id = a.region_id\nwhere date_trunc('quarter', s.canceled_at) = :date_1\n and a.is_test = false\n and a.account_id not in (:id_list_1)\ngroup by 1 order by 2 desc",
"question": { "source": "ticket", "asked_at": "2024-04-09T15:02:00Z", "asker_role": "customer_success_lead",
"text": "How many accounts churned last quarter by region? Leave out the [N] accounts we moved to the reseller." },
"pairing": { "method": "ticket_links_saved_report", "confidence": "explicit", "queries_in_pair": 6 },
"schema_snapshot": { "id": "schema_2024_04", "captured": "2024-04-01", "tables_visible_to_role": 412 },
"tables_referenced": [
{ "table": "analytics.fct_subscriptions", "columns": ["account_id", "canceled_at"] },
{ "table": "analytics.dim_accounts", "columns": ["account_id", "region_id", "is_test"] },
{ "table": "analytics.dim_regions", "columns": ["region_id", "region_name"] }
],
"execution": { "status": "success", "started_at": "2024-04-09T16:41:27Z", "elapsed_ms": 2310,
"bytes_scanned": 48211968, "error": null },
"origin": { "client": "sql_editor", "written_by": "human", "basis": "client_application_and_no_tool_comment" },
"revision_of": { "query_id": "q_58b209", "change": "count_distinct_after_join_fan_out",
"previous_status": "success", "previous_rows": 5 },
"session_outcome": { "final_query_id": "q_58b20e", "evidence": "saved_as_report_and_linked_in_ticket" },
"result_shape": { "columns": [ { "name": "region_name", "type": "text" }, { "name": "churned", "type": "number" } ], "rows": 5 },
"masking": { "literals_masked": { "date": 1, "id_list": 1 }, "parses_after_masking": true }
}Synthetic record for illustration. Field names, structure and format are agreed per order.
What AI teams use it for
Text-to-SQL on enterprise schemas
Questions as business users wrote them, paired with the SQL an analyst settled on, train models on wide schemas with legacy names.
Repairing a failed query
A failed statement, the engine's error message and the next statement form a repair example in the real dialect.
Multi-step analytics agents
Whole sessions show the order of work: look at the schema, sample rows, attempt, check a total, revise.
Schema linking and table choice
Which of several similar tables analysts used for a given kind of question is evidence no schema file contains.
Evaluation on unseen schemas
Held-out pairs from a private warehouse test a model on a schema and a vocabulary that were never published.
Use-case guides: Coding agents, Enterprise and computer-use agents, Private evaluation sets
What makes this data valuable
Pairing method stated
Each pair says whether it rests on an explicit link, a saved report or an inference.
Session order intact
Statements keep their sequence and timing, so a correction can be read as one.
Failures kept
Failed statements arrive with the engine's error code and message, not filtered out.
Dated schema snapshot
The schema matches the period of the queries, not the warehouse as it stands today.
Human and machine SQL separated
Statements from dashboards, transformation jobs and loaders are labeled or removed.
Acceptance evidence
The accepted query in a session is identified by what happened to it afterward.
Record timeline
SQL query dataset
Where the question lives
A warehouse records the query and nothing about why it was run. Its history view typically holds the statement text, the user, the start time, the status and the bytes scanned. The question was asked somewhere else: a data-request ticket, a thread in a requests channel, an email, a meeting. Without the question a query log is a corpus of SQL, useful for learning a dialect and a schema, but text-to-SQL needs the text. Most of a raw history is not analyst work either. Dashboards refreshing, transformation jobs, loaders and monitors often issue more statements than people do. dbt by default adds a comment naming itself to each statement, and BI tools such as Looker and Metabase can tag theirs with a comment or, on some connections, a job label. Each is a setting, so ask how machine-issued SQL was identified.
Pairs are rebuilt from three kinds of evidence, in falling order of strength. Explicit: the ticket links to the saved query or report, or the analyst pasted the SQL into the reply. Tool-internal: a saved question in Metabase or a report in Mode or Hex carries a title and description the analyst wrote. Inferred: the analyst assigned to the ticket ran a session against the relevant tables between the time it was opened and the time it was answered. Each pair should carry its method and a confidence level.
A saved-query title is not a question. "Churn by region v3" names an output and was written after the SQL. The request said which accounts to leave out and left "last quarter" for the analyst to read as fiscal or calendar. That ambiguity and the clarifying replies are what a model must learn to resolve, and titles carry none of it. One ticket also tends to produce several queries, so pairing works at the level of the session.
A session is a chain of corrections
The most widely used public text-to-SQL sets give one question, one compact schema and one reference query, and several of the best known run on SQLite, not a warehouse dialect. A real session begins before the first attempt. The analyst searches the information schema, selects a few rows to look at, and lists the distinct values of a status column. The first attempt then fails: an invalid identifier because the column is not named as expected, an ambiguous column in a join, a non-aggregated column missing from the GROUP BY, a timestamp compared with a string. The engine's own error text and the statement that followed make a repair pair in that dialect.
The harder failures raise no error. A join fans out and revenue doubles. The filter uses created_at where the business meant the close date. Soft-deleted rows and test accounts were not excluded. The analyst sees that a total does not tie to a known figure, runs a count to check, and rewrites. All three statements report success, so the correction is visible only as a sequence, and only if revisions are linked. The last statement of a session is not always the accepted one, since people give up. Acceptance needs its own evidence: the query was saved, scheduled or sent to the requester.
The schema is part of the difficulty. A warehouse keeps orders, orders_v2, stg_orders and fct_orders side by side, and only the log shows which one analysts queried for a given kind of question. The information schema describes today, while a query from two years ago may name columns that no longer exist, so each query needs a schema snapshot dated near its run. Depth is limited too. Warehouses keep query history for a set window, so older sessions exist only where the team exported them.
What to check before licensing
- Ask for the count of pairs by method (explicit link, saved report, inferred) and read a sample of each against the query it is paired with.
- Ask how statements written by people were separated from BI, transformation and scheduled statements, and look for generated SQL in the sample.
- Check that literal values in WHERE clauses are masked: names, emails and account numbers in comparisons, IN lists, LIKE patterns, pasted VALUES lists and comments. Confirm the masked text still parses.
- Confirm result sets are excluded or de-identified, and look for result rows or screenshots pasted into the request threads.
- Ask for the retention window of each query-history source, the earliest date in the delivery, and whether long statements were truncated or had to be reassembled from chunks.
- Compare schema snapshot dates with query dates, and count queries that reference a table or column absent from their snapshot.
- Confirm failed and abandoned statements were kept, and ask whether session boundaries come from the warehouse's session ID or from a time-gap rule.
Delivery No files move before a signed license. A listing or a request grants no files by itself.
How licensing works through SourceX
- 1
Define
Send the domain, modality, volume, format, timeline and permitted use you need.
- 2
Source
SourceX identifies businesses that hold matching data and are open to licensing it.
- 3
Qualify
Fit, rights and quality are checked, and you review samples before committing.
- 4
License
Scope, permitted use, exclusivity, price and obligations are agreed in writing.
- 5
Deliver
Approved data is prepared, de-identified where required and transferred securely.
Questions Acquisition Partners ask
Why are unpaired query logs less useful for text-to-SQL?
Because text-to-SQL training needs the text. A query history gives the SQL and its outcome but not the request, so a model can learn the dialect and the schema from it and nothing about turning a business question into a query. Unpaired statements still help with schema grounding and should be labeled as unpaired.
Where does the business question come from?
From wherever the request was made. That is usually a data-request ticket, a message in a requests channel, or the description on a saved report. Each pair should record the source of its question and how it was joined to its queries, and saved-query titles should be kept apart, not presented as questions.
Are query results included?
Only where your spec scopes them in and they can be de-identified. Result sets can hold customer rows, so they are either excluded or de-identified, and you should confirm which applies to your dataset. Where they are excluded, each query can still carry the shape of its result: column names, types and row count. If you need result values for execution-based grading, say so in your request, because that data then has to be scoped and de-identified too.
How are literal values inside queries masked?
Typed placeholders are the method to specify, because each literal is replaced and the statement keeps its structure. Analysts type names, emails and account numbers straight into WHERE clauses and IN lists, and sometimes paste whole customer lists into a query. The method used is recorded for each dataset. Check on the sample that masked statements still parse in their dialect. No method is perfect.
Can the queries be executed?
Not against the original data, which is not part of this dataset. You receive the schema, the query text and the recorded outcome. One option is to populate the schema with synthetic rows, which tests that a query runs but not that it returns the original answer.
How far back does query history go?
Only as far as the warehouse and the partner kept it. Each engine holds its query history for a set window, and some system tables keep statement text for a much shorter time. Partners that export history to their own tables hold more. Ask for the earliest date with full session logs.
Related datasets
- Database schemas, migrations and stored procedures
Production schema definitions with the migration chain, procedural code and the review and rollback record
- Analysis notebooks with executed outputs
Internal analysis notebooks with code, markdown, saved outputs, charts and links to the request and the consumer of the result
- Data pipeline code with run history
Pipeline and transformation code with commit history, run records, data-test results and lineage
- Real-world spreadsheets and financial models
Working Excel and Google Sheets files with formulas, links and version history
- Statistical analysis code in R, SAS and Stata
Analysis programs with the specification they implement, run logs, outputs and validation records
Evaluating this data for procurement?
Diligence packets are prepared per dataset. Rights, privacy processing and quality differ between datasets.
Request dataset diligenceTell us what your models need
Send your spec — domain, volume, format, timeline and permitted use — and SourceX will match it against partner data and come back with what can be licensed.
Updated 25 November 2026.