EUVIMEDEUVIMED entdecken
Crossref

Dialect-Agnostic SQL Parsing via LLM-Based Segmentation

Junwen An, Kabilan Mahathevan, Manuel Rigger

Proceedings of the ACM on Management of Data · 18.05.2026 · 4 (3) · 1-28

DOI: 10.1145/3802038 ↗

Kurz gefasst

Fachartikel in der Zeitschrift Proceedings of the ACM on Management of Data, online erschienen am 18.05.2026. Verfasst von Junwen An und 2 weiteren Autor:innen. Die Arbeit nennt 93 Literaturangaben. Gefördert von: Ministry of Education, Singapore.

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

SQL is a widely adopted language for querying data, which has led to the development of various SQL analysis and rewriting tools. However, due to the diversity of SQL dialects, such tools often fail when encountering unrecognized dialect-specific syntax. While Large Language Models (LLMs) have shown promise in understanding SQL queries, their inherent limitations in handling hierarchical structures and hallucination risks limit their direct applicability in parsing. To address these limitations, we propose SQLFlex, a novel query rewriting framework that integrates grammar-based parsing with LLM-based segmentation to parse diverse SQL dialects robustly. Our core idea is to decompose hierarchical parsing to sequential segmentation tasks, which better aligns with the strength of LLMs and improves output reliability through validation checks. Specifically, SQLFlex uses clause-level segmentation and expression-level segmentation as two strategies that decompose elements on different levels of a query. We extensively evaluated SQLFlex on both real-world use cases and in a standalone evaluation. In SQL linting, SQLFlex outperforms SQLFluff in ANSI mode by 63.68% in F1 score while matching its dialect-specific mode performance. In test-case reduction, SQLFlex outperforms SQLess by up to 10 times in simplification rate. In the standalone evaluation, it parses 91.55% to 100% of queries across eight distinct dialects, outperforming all baseline parsers. We believe SQLFlex can serve as a foundation for many query analysis and rewriting use cases.

Förderung

  • Ministry of Education, Singapore

Zitieren

APA

An, J., Mahathevan, K., & Rigger, M. (2026). Dialect-Agnostic SQL Parsing via LLM-Based Segmentation. Proceedings of the ACM on Management of Data, 4(3), 1-28. https://doi.org/10.1145/3802038

Vancouver

An J, Mahathevan K, Rigger M. Dialect-Agnostic SQL Parsing via LLM-Based Segmentation. Proceedings of the ACM on Management of Data. 2026;4(3):1-28. doi:10.1145/3802038

BibTeX
@article{An2026,
  author = {An, Junwen and Mahathevan, Kabilan and Rigger, Manuel},
  title = {Dialect-Agnostic SQL Parsing via LLM-Based Segmentation},
  journal = {Proceedings of the ACM on Management of Data},
  year = {2026},
  volume = {4},
  number = {3},
  pages = {1--28},
  doi = {10.1145/3802038}
}
Kostenlos starten →