{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,7,9]],"date-time":"2026-07-09T04:59:01Z","timestamp":1783573141217,"version":"3.55.0"},"reference-count":41,"publisher":"MDPI AG","issue":"8","license":[{"start":{"date-parts":[[2025,7,24]],"date-time":"2025-07-24T00:00:00Z","timestamp":1753315200000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"funder":[{"name":"Doctoral Fund of Tianjin Normal University","award":["52XB1619"],"award-info":[{"award-number":["52XB1619"]}]},{"name":"Open Fund of Tianjin Geospatial Information Technology Engineering Center","award":["52XB1619"],"award-info":[{"award-number":["52XB1619"]}]}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["IJGI"],"abstract":"<jats:p>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.<\/jats:p>","DOI":"10.3390\/ijgi14080288","type":"journal-article","created":{"date-parts":[[2025,7,24]],"date-time":"2025-07-24T15:19:22Z","timestamp":1753370362000},"page":"288","update-policy":"https:\/\/doi.org\/10.3390\/mdpi_crossmark_policy","source":"Crossref","is-referenced-by-count":8,"title":["GPT-Based Text-to-SQL for Spatial Databases"],"prefix":"10.3390","volume":"14","author":[{"given":"Hui","family":"Wang","sequence":"first","affiliation":[{"name":"Department of Geography, Tianjin Normal University, Tianjin 300387, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Li","family":"Guo","sequence":"additional","affiliation":[{"name":"Institute of Geospatial Information, Information Engineering University, Zhengzhou 450001, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Yubin","family":"Liang","sequence":"additional","affiliation":[{"name":"Department of Geography, Tianjin Normal University, Tianjin 300387, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Le","family":"Liu","sequence":"additional","affiliation":[{"name":"Faculty of Architectural Engineering, Tianjin University, Tianjin 300350, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Jiajin","family":"Huang","sequence":"additional","affiliation":[{"name":"Faculty of Information Technology, Beijing University of Technology, Beijing 100124, China"},{"name":"Beijing International Collaboration Base on Brain Informatics and Wisdom Services, Beijing 100124, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"1968","published-online":{"date-parts":[[2025,7,24]]},"reference":[{"key":"ref_1","doi-asserted-by":"crossref","first-page":"1","DOI":"10.1177\/2053951716661366","article-title":"Introduction: Spatial Big Data and Everyday Life","volume":"3","author":"Leszczynski","year":"2016","journal-title":"Big Data Soc."},{"key":"ref_2","doi-asserted-by":"crossref","unstructured":"Liu, M., Wang, X., and Xu, J. (2023, January 23\u201325). NALSD: A Natural Language Interface for Spatial Databases. Proceedings of the 18th International Symposium on Spatial and Temporal Data, Calgary, AB, Canada.","DOI":"10.1145\/3609956.3609974"},{"key":"ref_3","doi-asserted-by":"crossref","unstructured":"Liu, M., Wang, X., Xu, J., and Lu, H. (2023, January 13\u201316). NALSpatial: An Effective Natural Language Transformation Framework for Queries over Spatial Data. Proceedings of the 31st ACM International Conference on Advances in Geographic Information Systems, Hamburg, Germany.","DOI":"10.1145\/3589132.3625600"},{"key":"ref_4","doi-asserted-by":"crossref","first-page":"427","DOI":"10.1007\/s10707-023-00494-5","article-title":"NALMO: Transforming Queries in Natural Language for Moving Objects Databases","volume":"27","author":"Wang","year":"2023","journal-title":"GeoInformatica"},{"key":"ref_5","doi-asserted-by":"crossref","unstructured":"Liu, J., Shen, D., Zhang, Y., Dolan, B., Carin, L., and Chen, W. (2022, January 26\u201327). What Makes Good In-Context Examples for GPT-3?. Proceedings of the 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures, Dublin, Ireland.","DOI":"10.18653\/v1\/2022.deelio-1.10"},{"key":"ref_6","doi-asserted-by":"crossref","unstructured":"Guo, C., Tian, Z., Tang, J., Wang, P., Wen, Z., Yang, K., and Wang, T. (2023, January 15\u201319). Prompting GPT-3.5 for Text-to-SQL with De-semanticization and Skeleton Retrieval. Proceedings of the Trends in Artificial Intelligence\u201420th Pacific Rim International Conference on Artificial Intelligence, Jakarta, Indonesia.","DOI":"10.1007\/978-981-99-7022-3_23"},{"key":"ref_7","unstructured":"Pourreza, M., and Rafiei, D. (2024, January 10\u201316). DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction. Proceedings of the 37th International Conference on Neural Information Processing Systems, New Orleans, LA, USA."},{"key":"ref_8","unstructured":"Zelle, J.M., and Mooney, R.J. (1996, January 4\u20138). Learning to Parse Database Queries using Inductive Logic Programming. Proceedings of the Thirteenth National Conference on Artificial Intelligence, Portland, OR, USA."},{"key":"ref_9","doi-asserted-by":"crossref","unstructured":"Tang, L.R., and Mooney, R.J. (2000, January 7\u20138). Automated Construction of Database Interfaces: Intergrating Statistical and Relational Learning for Semantic Parsing. Proceedings of the 2000 Joint SIGDAT Conference on Empirical Methods in Natural Language Processing and Very Large Corpora, Hong Kong, China.","DOI":"10.3115\/1117794.1117811"},{"key":"ref_10","unstructured":"Iyer, S., Konstas, I., Cheung, A., Krishnamurthy, J., and Zettlemoyer, L. (August, January 30). Learning a Neural Semantic Parser from User Feedback. Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, Vancouver, BC, Canada."},{"key":"ref_11","unstructured":"Zhong, V., Xiong, C., and Socher, R. (2017). Seq2SQL: Generating Structured Queries from Natural Language Using Reinforcement Learning. arXiv."},{"key":"ref_12","doi-asserted-by":"crossref","unstructured":"Yu, T., Zhang, R., Yang, K., Yasunaga, M., Wang, D., Li, Z., Ma, J., Li, I., Yao, Q., and Roman, S. (November, January 31). Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels, Belgium.","DOI":"10.18653\/v1\/D18-1425"},{"key":"ref_13","doi-asserted-by":"crossref","unstructured":"Min, Q., Shi, Y., and Zhang, Y. (2019, January 3\u20137). A Pilot Study for Chinese SQL Semantic Parsing. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing, Hong Kong, China.","DOI":"10.18653\/v1\/D19-1377"},{"key":"ref_14","doi-asserted-by":"crossref","unstructured":"Wang, L., Zhang, A., Wu, K., Sun, K., Li, Z., Wu, H., Zhang, M., and Wang, H. (2020, January 16\u201320). DuSQL: A Large-Scale and Pragmatic Chinese Text-to-SQL Dataset. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing, Online.","DOI":"10.18653\/v1\/2020.emnlp-main.562"},{"key":"ref_15","doi-asserted-by":"crossref","unstructured":"Gan, Y., Chen, X., Huang, Q., Purver, M., Woodward, J.R., Xie, J., and Huang, P. (2021, January 1\u20136). Towards Robustness of Text-to-SQL Models against Synonym Substitution. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, Online.","DOI":"10.18653\/v1\/2021.acl-long.195"},{"key":"ref_16","doi-asserted-by":"crossref","unstructured":"Gan, Y., Chen, X., and Purver, M. (2021, January 7\u201311). Exploring Underexplored Limitations of Cross-Domain Text-to-SQL Generalization. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, Punta Cana, Dominican Republic.","DOI":"10.18653\/v1\/2021.emnlp-main.702"},{"key":"ref_17","doi-asserted-by":"crossref","unstructured":"Shaw, P., Chang, M.-W., Pasupat, P., and Toutanova, K. (2021, January 1\u20136). Compositional Generalization and Natural Language Variation: Can a Semantic Parsing Approach Handle Both?. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing, Online.","DOI":"10.18653\/v1\/2021.acl-long.75"},{"key":"ref_18","unstructured":"Li, J., Hui, B., Qu, G., Yang, J., Li, B., Li, B., Wang, B., Qin, B., Geng, R., and Huo, N. (2023, January 10\u201316). Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs. Proceedings of the 37th International Conference on Neural Information Processing Systems, New Orleans, LA, USA."},{"key":"ref_19","unstructured":"Sutskever, I., Vinyals, O., and Le, Q.V. (2014, January 8\u201313). Sequence to Sequence Learning with Neural Networks. Proceedings of the 27th International Conference on Neural Information Processing Systems, Montreal, QC, Canada."},{"key":"ref_20","unstructured":"Guo, J., Zhan, Z., Gao, Y., Xiao, Y., Lou, J.-G., Liu, T., and Zhang, D. (August, January 28). Towards Complex Text-to-SQL in Cross-Domain Database with Intermediate Representation. Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy."},{"key":"ref_21","first-page":"309","article-title":"RYANSQL: Recursively Applying Sketch-Based Slot Fillings for Complex Text-to-SQL in Cross-Domain Databases","volume":"47","author":"Choi","year":"2021","journal-title":"Comput. Linguist."},{"key":"ref_22","unstructured":"Hwang, W., Yim, J., Park, S., and Seo, M. (2019, January 8\u201314). A Comprehensive Exploration on WikiSQL with Table-Aware Word Contextualization. Proceedings of the 33rd International Conference on Neural Information Processing Systems, Vancouver, BC, Canada."},{"key":"ref_23","doi-asserted-by":"crossref","unstructured":"Yin, P., Neubig, G., Yih, W.-t., and Riedel, S. (2020, January 5\u201310). TaBERT: Pretraining for Joint Understanding of Textual and Tabular Data. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online.","DOI":"10.18653\/v1\/2020.acl-main.745"},{"key":"ref_24","doi-asserted-by":"crossref","unstructured":"Herzig, J., Nowak, P.K., M\u00fcller, T., Piccinno, F., and Eisenschlos, J. (2020, January 5\u201310). TAPAS: Weakly Supervised Table Parsing via Pre-Training. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online.","DOI":"10.18653\/v1\/2020.acl-main.398"},{"key":"ref_25","unstructured":"Yu, T., Wu, C.-S., Lin, X.V., Wang, B., Tan, Y.C., Yang, X., Radev, D.R., Socher, R., and Xiong, C. (2021, January 3\u20137). Grappa: Grammar-Augmented Pre-Training for Table Semantic Parsing. Proceedings of the 9th International Conference on Learning Representations, Online."},{"key":"ref_26","doi-asserted-by":"crossref","unstructured":"Li, J., Wang, W., Ku, W.-S., Tian, Y., and Wang, H. (2019, January 5\u20138). SpatialNLI: A spatial Domain Natural Language Interface to Databases Using Spatial Comprehension. Proceedings of the 27th ACM International Conference on Advances in Geographic Information Systems, Chicago, IL, USA.","DOI":"10.1145\/3347146.3359069"},{"key":"ref_27","doi-asserted-by":"crossref","first-page":"29","DOI":"10.1007\/s10707-023-00496-3","article-title":"Multilingual Spatial Domain Natural Language Interface to Databases","volume":"28","author":"Wang","year":"2024","journal-title":"GeoInformatica"},{"key":"ref_28","unstructured":"Hong, Z., Yuan, Z., Zhang, Q., Chen, H., Dong, J., Huang, F., and Huang, X. (2024). Next-Generation Database Interfaces: A Survey of LLM-Based Text-to-SQL. arXiv."},{"key":"ref_29","doi-asserted-by":"crossref","unstructured":"Liu, X., Shen, S., Li, B., Ma, P., Jiang, R., Zhang, Y., Fan, J., Li, G., Tang, N., and Luo, Y. (2024). A Survey of NL2SQL with Large Language Models: Where Are We, and Where Are We Going?. arXiv.","DOI":"10.1109\/TKDE.2025.3592032"},{"key":"ref_30","doi-asserted-by":"crossref","unstructured":"Shi, L., Tang, Z., Zhang, N., Zhang, X., and Yang, Z. (2024). A Survey on Employing Large Language Models for Text-to-SQL Tasks. arXiv.","DOI":"10.1145\/3737873"},{"key":"ref_31","unstructured":"Dong, X., Zhang, C., Ge, Y., Mao, Y., Gao, Y., Chen, L., Lin, J., and Lou, D. (2023). C3: Zero-Shot Text-to-SQL with ChatGPT. arXiv."},{"key":"ref_32","doi-asserted-by":"crossref","unstructured":"Zhang, H., Cao, R., Chen, L., Xu, H., and Yu, K. (2023, January 6\u201310). ACT-SQL: In-Context Learning for Text-to-SQL with Automatically-Generated Chain-of-Thought. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, Singapore.","DOI":"10.18653\/v1\/2023.findings-emnlp.227"},{"key":"ref_33","doi-asserted-by":"crossref","first-page":"1132","DOI":"10.14778\/3641204.3641221","article-title":"Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation","volume":"17","author":"Gao","year":"2024","journal-title":"Proc. Vldb Endow."},{"key":"ref_34","doi-asserted-by":"crossref","unstructured":"Wu, H., Shen, Z., Hou, S., Liang, J., Jiao, H., Qing, Y., Zhang, X., Li, X., Gui, Z., and Guan, X. (2025). AutoGEEval: A Multimodal and Automated Evaluation Framework for Geospatial Code Generation on GEE with Large Language Models. ISPRS Int. J.-Geo-Inf., 14.","DOI":"10.3390\/ijgi14070256"},{"key":"ref_35","doi-asserted-by":"crossref","first-page":"2509812","DOI":"10.1080\/17538947.2025.2509812","article-title":"Chain-of-Programming (CoP): Empowering Large Language Models for Geospatial Code Generation Task","volume":"18","author":"Hou","year":"2025","journal-title":"Int. J. Digit. Earth"},{"key":"ref_36","doi-asserted-by":"crossref","unstructured":"Hou, S., Liang, J., Zhao, A., and Wu, H. (2025). GEE-OPs: An Operator Knowledge Base for Geospatial Code Generation on the Google Earth Engine Platform Powered by Large Language Models. Geo-Spat. Inf. Sci., 1\u201322.","DOI":"10.1080\/10095020.2025.2505556"},{"key":"ref_37","first-page":"104456","article-title":"GeoCode-GPT: A Large Language Model for Geospatial Code Generation","volume":"138","author":"Hou","year":"2025","journal-title":"Int. J. Appl. Earth Obs. Geoinf."},{"key":"ref_38","doi-asserted-by":"crossref","first-page":"113624","DOI":"10.1016\/j.knosys.2025.113624","article-title":"Geo-FuB: A Method for Constructing An Operator-Function Knowledge Base for Geospatial Code Generation with Large Language Models","volume":"319","author":"Hou","year":"2025","journal-title":"Knowl.-Based Syst."},{"key":"ref_39","doi-asserted-by":"crossref","unstructured":"Jiang, Y., and Yang, C. (2024). Is ChatGPT a Good Geospatial Data Analyst? Exploring the Integration of Natural Language into Structured Query Language within a Spatial Database. ISPRS Int. J.-Geo-Inf., 13.","DOI":"10.3390\/ijgi13010026"},{"key":"ref_40","doi-asserted-by":"crossref","unstructured":"Nan, L., Zhao, Y., Zou, W., Ri, N., Tae, J., Zhang, E., Cohan, A., and Radev, D. (2023, January 6\u201310). Enhancing Text-to-SQL Capabilities of Large Language Models: A Study on Prompt Design Strategies. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, Singapore.","DOI":"10.18653\/v1\/2023.findings-emnlp.996"},{"key":"ref_41","unstructured":"Chang, S., and Fosler-Lussier, E. (2023). How to Prompt LLMs for Text-to-SQL: A Study in Zero-Shot, Single-Domain, and Cross-Domain Settings. arXiv."}],"container-title":["ISPRS International Journal of Geo-Information"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.mdpi.com\/2220-9964\/14\/8\/288\/pdf","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,10,9]],"date-time":"2025-10-09T18:15:38Z","timestamp":1760033738000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.mdpi.com\/2220-9964\/14\/8\/288"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,7,24]]},"references-count":41,"journal-issue":{"issue":"8","published-online":{"date-parts":[[2025,8]]}},"alternative-id":["ijgi14080288"],"URL":"https:\/\/doi.org\/10.3390\/ijgi14080288","relation":{},"ISSN":["2220-9964"],"issn-type":[{"value":"2220-9964","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,7,24]]}}}