File size: 4,695 Bytes
8b85b94
 
fdd5401
 
 
 
 
 
 
 
 
 
0f3fa98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
license: mit
task_categories:
- translation
language:
- pt
tags:
- Text2SQL
- Text-to-SQL
pretty_name: AtlasSQL-BR
size_categories:
- 1K<n<10K
---

# AtlasSQL-BR

AtlasSQL-BR is a novel geospatial Text-to-SQL dataset in Brazilian Portuguese, built upon real-world open-government data. Integrating school census data, public facility registries, and Brazil's official geographic boundary hierarchies, this dataset provides a robust benchmark for evaluating and training models on spatial queries.

## 📊 Dataset Architecture and Structure

The database schema underlying AtlasSQL-BR is organized around thematic public facility tables and their associated geographic boundary layers. This multi-level structure requires models to reason about spatial containment across different administrative granularities within a single SQL statement.

* **Thematic Tables (Point Geometries):** The core table is `microdados_ed_basica`, derived from the Brazilian School Census, containing hundreds of infrastructural and pedagogical attributes per school. The schema also includes georeferenced records for other public facilities: libraries, CRAS, CREAS, and Centros POP.
* **Boundary Tables (Polygon Geometries):** The dataset incorporates all seven official geographic boundary levels from IBGE: country, macro-region, state, municipality, district, neighborhood, and street.
* **Spatial Operators:** Spatial relationships between facility points and boundary polygons are resolved using PostGIS extensions. The dataset covers a vocabulary of 22 PostGIS spatial functions (e.g., `ST_Intersects`, `ST_Within`, `ST_Contains`, `ST_Distance`).

### Data Fields
Based on the dataset structure, each record contains the following fields:
* `question`: The natural language query in Brazilian Portuguese.
* `sql_code`: The corresponding executable PostGIS/SQL query.
* `territorial_division`: The administrative boundary level relevant to the query.
* `level`: The structural complexity tier of the query.
* `geospatial_functions`: The primary PostGIS functions required to solve the query.
* `source`: Indicates the origin of the data. It can be `base_dataset` (the original 980 manually annotated questions) or partitions generated by data augmentation techniques (such as `delete`, `insert`, `swap`, `synonym`, `translate`).

## 📈 Complexity Tiers

The dataset comprises manually annotated question-SQL pairs classified into four complexity tiers based on the structural properties of the SQL query (all criteria are AND-combined within each tier):

| Tier | Structural Criteria |
| :--- | :--- |
| **Easy** | <1 JOIN; no aggregations; no subqueries; direct spatial filter. |
| **Medium** | 2-3 JOINs; no aggregations; multiple spatial conditions. |
| **Hard** | 3-4 JOINs; >1 aggregation (COUNT, SUM, AVG); multiple spatial functions. |
| **Very Hard** | 4+ JOINs; multiple aggregations; subqueries and/or CTEs; window functions (ROW_NUMBER, RANK, DENSE_RANK); CASE WHEN; possible UNION. |

## 📁 Files and Reproducibility

The dataset is divided into standard `train.parquet` and `validation.parquet` splits. 

**⚠️ Important Note on Reproducibility:**
The baseline experiments documented in the original paper were conducted **exclusively** on the original 980 question-SQL pairs. The dataset files available here also include additional data generated through data augmentation techniques. 

To exactly replicate the experiments and results from the original paper, you **must**:
1. Use the dataset version associated with the **`paper-released`** tag.
2. Filter the data to include **only** the records where the `source` column is exactly `base_dataset`. The other partitions (`delete`, `insert`, `swap`, `synonym`, `translate`) contain synthetic augmented data and should be excluded when reproducing the paper's base results.

### How to load the dataset for reproducibility (Python)

You can easily download and filter the dataset using the Hugging Face `datasets` library to match the exact setup used in the paper:

```python
from datasets import load_dataset

# 1. Load the dataset using the specific tag for the paper's release
dataset = load_dataset("datafromlopes/atlas-sql-br", revision="paper-released")

# 2. Filter both train and validation splits to include only the original 980 questions
base_train = dataset["train"].filter(lambda x: x["source"] == "base_dataset")
base_validation = dataset["validation"].filter(lambda x: x["source"] == "base_dataset")

print(f"Original Train size: {len(base_train)}")
print(f"Original Validation size: {len(base_validation)}")
```

## ✒️ Citation

If you find this dataset useful for your research, please cite the original paper: