SPLASH 2025
Sun 12 - Sat 18 October 2025 Singapore
co-located with ICFP/SPLASH 2025

SQL’s widespread adoption has driven the development of numerous query analysis and rewriting tools. However, due to the diverse SQL dialects, these tools often fail with unrecognized dialect-specific syntax. While Large Language Models (LLMs) show promise for SQL interpretation, their limitations with hierarchical structures and hallucination risks prevent direct AST generation. We introduce SQLFlex, an approach that combines grammar-based parsing with LLM-based segmentation for robust dialect-agnostic query parsing. Our approach decomposes hierarchical parsing into sequential segmentation tasks, leveraging LLM strengths while ensuring reliability through validation. SQLFlex achieves 91.26% parsing success across eight SQL dialects and demonstrates practical effectiveness in real-world SQL linting and test case reduction applications.