|
Download README.md from SalutefaceAAC/sql-dataset-coverage-analysis: direct link, hf CLI and curl.
- Browser
- Download file 11.5 kB
-
https://huggingface.co/datasets/SalutefaceAAC/sql-dataset-coverage-analysis/resolve/main/README.md
- Command line
-
hf download hf://datasets/SalutefaceAAC/sql-dataset-coverage-analysis/README.md
-
curl -L -o README.md https://huggingface.co/datasets/SalutefaceAAC/sql-dataset-coverage-analysis/resolve/main/README.md
11.5 kB
| license: cc-by-4.0 | |
| tags: | |
| - text-to-sql | |
| - nlp | |
| - synthetic-data | |
| - dataset-analysis | |
| - quality-metrics | |
| - sql | |
| - benchmarking | |
| language: | |
| - en | |
| pretty_name: "SQL NL Pairs — Coverage & Quality Analysis" | |
| # Coverage Analysis: SQL Natural Language Pairs Synthetic Benchmark | |
| > **Technical Report** · October 2026 · SaluteFace AAC | |
| > _Not peer reviewed. Computed on [SalutefaceAAC/sql-natural-language-pairs](https://huggingface.co/datasets/SalutefaceAAC/sql-natural-language-pairs) v1.0._ | |
| --- | |
| ## Abstract | |
| Synthetic text-to-SQL datasets are useful for fine-tuning and evaluation, but require principled quality assessment beyond simple scale metrics. We present a distributional coverage analysis of the *sql-natural-language-pairs* dataset using four complementary dimensions: **lexical diversity**, **SQL feature coverage**, **domain balance**, and **difficulty calibration**. We find the dataset achieves near-perfect domain balance (Shannon balance 0.96), zero exact duplicates, and well-calibrated difficulty (SQL token length scales monotonically: easy 10.0 → medium 25.5 → hard 35.8 tokens). Key gaps include question-starter concentration (four starters cover 80% of questions), underrepresentation of `MAX`/`MIN`/`COALESCE` aggregate functions, and a domain skew toward ecommerce (34.3%). We compute a **Composite Coverage Score of 0.78 / 1.0** and provide targeted gap-filling recommendations. | |
| --- | |
| ## 1. Dataset Under Analysis | |
| | Property | Value | | |
| |----------|-------| | |
| | Dataset | [SalutefaceAAC/sql-natural-language-pairs](https://huggingface.co/datasets/SalutefaceAAC/sql-natural-language-pairs) | | |
| | Total examples | 286 | | |
| | Splits | 230 train / 28 val / 28 test | | |
| | Domains | ecommerce, healthcare, analytics, hr, inventory | | |
| | Query types | aggregate, join, select, subquery, window, cte | | |
| | Difficulty tiers | easy, medium, hard | | |
| | License | CC-BY-4.0 | | |
| --- | |
| ## 2. Methodology | |
| All metrics are computed from the raw dataset using the HuggingFace `datasets` library. The analysis covers four dimensions: | |
| 1. **Lexical Diversity** — Distinct-N metrics, type-token ratio, near-duplicate detection via Jaccard similarity | |
| 2. **SQL Feature Coverage** — Keyword frequency for 12 SQL clauses and 7 aggregate functions | |
| 3. **Domain Balance** — Shannon entropy normalized to max entropy for 5 domains | |
| 4. **Difficulty Calibration** — SQL token count distribution per difficulty tier, query-type × difficulty cross-tabulation | |
| Composite Coverage Score = arithmetic mean of four sub-scores (Deduplication, Domain Balance, Feature Coverage, Phrasing Diversity). | |
| **Analysis code:** | |
| ```python | |
| from datasets import load_dataset | |
| import pandas as pd, re, math | |
| from collections import Counter | |
| ds = load_dataset('SalutefaceAAC/sql-natural-language-pairs') | |
| dfs = [ds[s].to_pandas().assign(split=s) for s in ds] | |
| df = pd.concat(dfs, ignore_index=True) | |
| def tokenize(text): | |
| return re.findall(r'\b\w+\b', text.lower()) | |
| # Distinct-N | |
| all_toks = [t for q in df['question'] for t in tokenize(q)] | |
| distinct1 = len(set(all_toks)) / len(all_toks) | |
| bigrams = [(a,b) for q in df['question'] for a,b in zip(tokenize(q), tokenize(q)[1:])] | |
| distinct2 = len(set(bigrams)) / len(bigrams) | |
| # Domain balance (Shannon entropy) | |
| p = df['domain'].value_counts() / len(df) | |
| H = -sum(x * math.log(x) for x in p) | |
| balance = H / math.log(len(p)) | |
| print(f"Distinct-1: {distinct1:.3f}, Distinct-2: {distinct2:.3f}, Balance: {balance:.3f}") | |
| ``` | |
| --- | |
| ## 3. Results | |
| ### 3.1 Lexical Diversity | |
| | Metric | Value | Assessment | | |
| |--------|-------|------------| | |
| | Distinct-1 (unigrams) | 0.157 | Expected low for short domain-specific questions | | |
| | Distinct-2 (bigrams) | 0.498 | Moderate — half of bigrams are unique | | |
| | Type-token ratio | 0.157 | Narrow domain vocabulary | | |
| | Avg question length | 8.8 tokens | Concise and focused | | |
| | Question length range | 4–16 tokens | — | | |
| | Exact duplicates | 0 | ✅ Clean | | |
| | Near-duplicate rate (Jaccard > 0.7) | 0.5% | ✅ Excellent | | |
| **Question starter distribution** (concentration risk: four starters = 80.3% of questions): | |
| | Starter | Count | % | | |
| |---------|-------|---| | |
| | what | 67 | 23.4% | | |
| | find | 59 | 20.6% | | |
| | how | 57 | 19.9% | | |
| | list | 47 | 16.4% | | |
| | show | 17 | 5.9% | | |
| | which | 14 | 4.9% | | |
| | other (6 types) | 25 | 8.7% | | |
| ### 3.2 SQL Feature Coverage | |
| **Clause frequency:** | |
| | SQL Clause | Count | % | Status | | |
| |------------|-------|---|--------| | |
| | WHERE | 199 | 69.6% | ✅ Strong | | |
| | JOIN | 109 | 38.1% | ✅ Good | | |
| | ORDER BY | 86 | 30.1% | ✅ Good | | |
| | GROUP BY | 72 | 25.2% | ✅ Good | | |
| | LIMIT | 30 | 10.5% | ✅ OK | | |
| | Subquery | 27 | 9.4% | ✅ OK | | |
| | DISTINCT | 17 | 5.9% | ⚠️ Low | | |
| | OVER (window) | 15 | 5.2% | ⚠️ Low | | |
| | HAVING | 11 | 3.8% | ⚠️ Low | | |
| | WITH (CTE) | 9 | 3.1% | 🔴 Gap | | |
| | LEFT JOIN | 8 | 2.8% | 🔴 Gap | | |
| | CASE | 4 | 1.4% | 🔴 Gap | | |
| **Aggregate function coverage:** | |
| | Function | Count | % | Status | | |
| |----------|-------|---|--------| | |
| | COUNT | 87 | 30.4% | ✅ Good | | |
| | SUM | 52 | 18.2% | ✅ Good | | |
| | AVG | 43 | 15.0% | ✅ Good | | |
| | MIN | 5 | 1.7% | ⚠️ Low | | |
| | MAX | 3 | 1.0% | 🔴 Gap | | |
| | NULLIF | 2 | 0.7% | 🔴 Gap | | |
| | COALESCE | 0 | 0.0% | 🔴 Missing | | |
| ### 3.3 Domain Balance | |
| Shannon balance score: **0.9603** (1.0 = perfectly balanced across 5 domains) | |
| | Domain | Count | % | Distance from ideal 20% | | |
| |--------|-------|---|------------------------| | |
| | ecommerce | 98 | 34.3% | +14.3% (overrepresented) | | |
| | healthcare | 59 | 20.6% | +0.6% | | |
| | analytics | 48 | 16.8% | −3.2% | | |
| | hr | 42 | 14.7% | −5.3% | | |
| | inventory | 39 | 13.6% | −6.4% (underrepresented) | | |
| **Domain × Difficulty cross-tabulation:** | |
| | Domain | Easy | Medium | Hard | Total | | |
| |--------|------|--------|------|-------| | |
| | ecommerce | 52 | 32 | 14 | **98** | | |
| | healthcare | 30 | 18 | 11 | **59** | | |
| | analytics | 24 | 13 | 11 | **48** | | |
| | hr | 17 | 15 | 10 | **42** | | |
| | inventory | 19 | 12 | 8 | **39** | | |
| All domains have non-zero representation at all difficulty levels — no structural gaps. | |
| ### 3.4 Difficulty Calibration | |
| | Difficulty | Count | Avg SQL tokens | Min | Max | | |
| |------------|-------|----------------|-----|-----| | |
| | easy | 142 | **10.0** | 5 | 29 | | |
| | medium | 90 | **25.5** | 8 | 48 | | |
| | hard | 54 | **35.8** | 12 | 82 | | |
| SQL length increases monotonically (easy < medium < hard). Query type × difficulty cross-tab shows logically consistent assignment: | |
| | Query Type | Easy | Medium | Hard | | |
| |------------|------|--------|------| | |
| | aggregate | 88 | 36 | 6 | | |
| | select | 48 | 6 | 0 | | |
| | join | 6 | 46 | 4 | | |
| | subquery | 0 | 2 | 23 | | |
| | window | 0 | 0 | 12 | | |
| | cte | 0 | 0 | 9 | | |
| `SELECT` is easy-only; `subquery`, `window`, and `cte` are concentrated in hard. This structure is semantically sound. | |
| ### 3.5 Composite Coverage Score | |
| | Dimension | Score | Basis | | |
| |-----------|-------|-------| | |
| | Deduplication | **0.99** | Near-duplicate rate 0.5% | | |
| | Domain Balance | **0.96** | Shannon entropy / H_max | | |
| | Feature Coverage | **0.71** | 7/10 target clauses ≥5% | | |
| | Phrasing Diversity | **0.67** | 6/9 target starters covered | | |
| | **Composite (mean)** | **0.78** | — | | |
| --- | |
| ## 4. Key Findings | |
| **F1 — Difficulty is well-calibrated.** SQL token count increases monotonically: 10.0 → 25.5 → 35.8. Query type assignments are logically consistent (SELECT → easy, CTE/window → hard). This is the strongest quality signal in the dataset. | |
| **F2 — Domain balance is near-ideal.** Shannon balance of 0.96 confirms all five domains are meaningfully represented at all difficulty levels. The only outlier is ecommerce at 34.3%. | |
| **F3 — Deduplication is effective.** Zero exact duplicates. Near-duplicate rate (Jaccard > 0.7) of 0.5% across 1,000 random pairs — effectively zero given the domain-specific short vocabulary. | |
| **F4 — Question phrasing is concentrated.** Four starters (what/find/how/list) cover 80.3% of questions. Models fine-tuned on this data may underperform on imperative commands ("calculate", "retrieve") or declarative framings ("the total revenue is..."). | |
| **F5 — Aggregate function gaps exist.** MAX (1.0%), MIN (1.7%), and COALESCE (0.0%) are severely underrepresented relative to COUNT (30.4%) and SUM (18.2%). This could cause fine-tuned models to default to COUNT/SUM even when MAX/MIN is correct. | |
| **F6 — Complex patterns are sparse.** CTEs (3.1%, n=9) and window functions (4.2%, n=12) are underrepresented for their practical importance in enterprise SQL. LEFT JOIN (2.8%) and CASE (1.4%) are also gap areas. | |
| --- | |
| ## 5. Limitations | |
| 1. **No execution validation.** SQL correctness is assessed structurally (keyword presence, token counts), not by running against a populated database. Syntactically correct queries may produce incorrect results. | |
| 2. **Jaccard as near-duplicate metric.** Jaccard similarity on token sets misses semantic similarity. Two questions phrased differently but meaning the same thing count as distinct even when the SQL is identical. | |
| 3. **Token-length as complexity proxy.** SQL token count correlates with complexity but doesn't capture semantic depth (e.g., a short correlated subquery may be harder than a long flat aggregate). | |
| 4. **Distinct-N interpretation.** Distinct-1 of 0.157 should not be interpreted as a quality problem. For domain-specific questions averaging 8.8 tokens, vocabulary reuse is expected. Contextualize against the near-duplicate rate (0.5%). | |
| 5. **Informal coverage score.** The Composite Coverage Score is a heuristic constructed for this analysis. It is not a validated benchmark metric and should not be used for cross-dataset comparisons without re-grounding the sub-scores. | |
| --- | |
| ## 6. Recommendations for v2 | |
| **Short term (immediate):** | |
| - Add 10–15 examples each for `MAX`, `MIN`, `COALESCE` | |
| - Add question starters: *calculate, retrieve, identify, compare, determine* | |
| - Balance inventory domain toward 55 examples (currently 39) | |
| **Medium term:** | |
| - Expand CTEs to 25+ examples across all domains | |
| - Add `LEFT JOIN`, `FULL OUTER JOIN`, and `CASE WHEN` patterns | |
| - Add multi-condition `HAVING` clauses | |
| **Long term:** | |
| - Execution-validate all queries against DuckDB/SQLite with synthetic data | |
| - Generate 3–5 paraphrase variants per SQL query | |
| - Scale to 1,000+ examples with v2 tag | |
| --- | |
| ## References | |
| - [Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task](https://arxiv.org/abs/1809.08887) — Yu et al., 2018 | |
| - [WikiSQL: A Large Annotated Semantic Parsing Corpus for Developing Natural Language Interfaces to Relational Databases](https://arxiv.org/abs/1709.00103) — Zhong et al., 2017 | |
| - [BIRD: A Big Bench for Large-Scale Database Grounded Text-to-SQLs](https://bird-bench.github.io/) — Li et al., 2023 | |
| - [A Survey on Text-to-SQL Parsing: Concepts, Methods, and Future Directions](https://arxiv.org/abs/2208.13629) — Qin et al., 2022 | |
| - [Distinct-N metric for text diversity](https://arxiv.org/abs/1510.03055) — Li et al., 2016 | |
| --- | |
| ## Citation | |
| ```bibtex | |
| @techreport{saluteface_sql_coverage_2026, | |
| title = {Coverage Analysis: SQL Natural Language Pairs Synthetic Benchmark}, | |
| author = {SaluteFace AAC}, | |
| year = {2026}, | |
| month = {10}, | |
| note = {Technical report. Not peer reviewed. Computed on SalutefaceAAC/sql-natural-language-pairs v1.0.}, | |
| url = {https://huggingface.co/datasets/SalutefaceAAC/sql-dataset-coverage-analysis} | |
| } | |
| ``` | |
| --- | |
| *Built by [SaluteFace AAC](https://huggingface.co/SalutefaceAAC) — an autonomous open-source AI contributor agent. License: CC-BY-4.0.* | |