Content area

Abstract

Text-to-SQL for spatial databases enables the translation of natural language questions into corresponding SQL queries, allowing non-experts to easily access spatial data, which has gained increasing attention from researchers. Previous research has primarily focused on rule-based methods. However, these methods have limitations when dealing with complicated or unknown natural language questions. While advanced machine learning models can be trained, they typically require large labeled training datasets, which are severely lacking for spatial databases. Recently, Generative Pre-Trained Transformer (GPT) models have emerged as a promising paradigm for Text-to-SQL tasks in relational databases, driven by carefully designed prompts. In response to the severe lack of datasets for spatial databases, we have created a publicly available dataset that supports both English and Chinese. Furthermore, we propose a GPT-based method to construct prompts for spatial databases, which incorporates geographic and spatial database knowledge into the prompts and requires only a small number of training samples, such as 1, 3, or 5 examples. Extensive experiments demonstrate that incorporating geographic and spatial database knowledge into prompts improves the accuracy of Text-to-SQL tasks for spatial databases. Our proposed method can help non-experts access spatial databases more easily and conveniently.

Details

1009240
Business indexing term
Identifier / keyword
Title
GPT-Based Text-to-SQL for Spatial Databases
Author
Wang, Hui 1 ; Guo, Li 2 ; Liang Yubin 1 ; Liu, Le 3 ; Huang Jiajin 4 

 Department of Geography, Tianjin Normal University, Tianjin 300387, China; [email protected] 
 Institute of Geospatial Information, Information Engineering University, Zhengzhou 450001, China; [email protected] 
 Faculty of Architectural Engineering, Tianjin University, Tianjin 300350, China; [email protected] 
 Faculty of Information Technology, Beijing University of Technology, Beijing 100124, China; [email protected], Beijing International Collaboration Base on Brain Informatics and Wisdom Services, Beijing 100124, China 
Volume
14
Issue
8
First page
288
Number of pages
18
Publication year
2025
Publication date
2025
Publisher
MDPI AG
Place of publication
Basel
Country of publication
Switzerland
Publication subject
e-ISSN
22209964
Source type
Scholarly Journal
Language of publication
English
Document type
Journal Article
Publication history
 
 
Online publication date
2025-07-24
Milestone dates
2025-05-20 (Received); 2025-07-22 (Accepted)
Publication history
 
 
   First posting date
24 Jul 2025
ProQuest document ID
3244039061
Document URL
https://www.proquest.com/scholarly-journals/gpt-based-text-sql-spatial-databases/docview/3244039061/se-2?accountid=208611
Copyright
© 2025 by the authors. Published by MDPI on behalf of the International Society for Photogrammetry and Remote Sensing. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/). Notwithstanding the ProQuest Terms and Conditions, you may use this content in accordance with the terms of the License.
Last updated
2026-01-16
Database
ProQuest One Academic