Text-to-SQL semantic parsing faces challenges in generalizing to cross-domain and complex queries. Recent research has employed a question decomposition strategy to enhance the parsing of complex SQL queries. However, this strategy encounters two major obstacles: (1) existing datasets lack question decomposition; (2) due to the syntactic complexity of SQL, most complex queries cannot be disentangled into sub-queries that can be readily recomposed. To address these challenges, we propose a new modular Query Plan Language (QPL) that systematically decomposes SQL queries into simple and regular sub-queries. We develop a translator from SQL to QPL by leveraging analysis of SQL server query optimization plans, and we augment the Spider dataset with QPL programs. Experimental results demonstrate that the modular nature of QPL benefits existing semantic-parsing architectures, and training text-to-QPL parsers is more effective than text-to-SQL parsing for semantically equivalent queries. The QPL approach offers two additional advantages: (1) QPL programs can be paraphrased as simple questions, which allows us to create a dataset of (complex question, decomposed questions). Training on this dataset, we obtain a Question Decomposer for data retrieval that is sensitive to database schemas. (2) QPL is more accessible to non-experts for complex queries, leading to more interpretable output from the semantic parser.
翻译:文本到SQL语义解析在跨领域和复杂查询的泛化上面临挑战。近期研究采用问题分解策略来增强复杂SQL查询的解析能力。然而,该策略面临两大障碍:(1)现有数据集缺乏问题分解;(2)由于SQL的句法复杂性,大多数复杂查询无法被分解为易于重新组合的子查询。为应对这些挑战,我们提出一种新的模块化查询计划语言(QPL),该语言能系统地将SQL查询分解为简单且规整的子查询。我们通过分析SQL服务器查询优化计划,开发了从SQL到QPL的转换器,并利用QPL程序扩充了Spider数据集。实验结果表明,QPL的模块化特性有益于现有语义解析架构,且对于语义等价的查询,训练文本到QPL解析器比文本到SQL解析更有效。QPL方法还具有两个额外优势:(1)QPL程序可被改写为简单问题,从而创建(复杂问题,分解后问题)的数据集。在该数据集上训练,我们获得了对数据库模式敏感的数据检索问题分解器。(2)对于非专家用户而言,QPL在复杂查询上更易理解,使语义解析器的输出更具可解释性。